Tell me more ×
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It's 100% free, no registration required.

I am using magento 1.7 and i need to display description of related products on product page. I am getting name ,image and URL of related products through related.phtml but not getting description.

And i also want add to cart button there which will add that related product to the cart.

Thanks in advance,

share|improve this question
what will $_item->getDescription() give you? – Mufaddal May 20 at 11:00

2 Answers

up vote 3 down vote accepted

Ok description is not loaded by default so what I had do was ugly way of displaying description on related product.

In foreach loop you can get product id from this $_item->getEntityId()

And from id load product model $product = Mage::getModel('catalog/product')->load($_item->getEntityId());

$product->getDescription() give you description of product.

And for add to cart button remove your checkbox input field put something like this

<a href="<?php echo Mage::getBaseUrl() ?>checkout/cart/add/product/<?php echo $_item->getId();?>">Add to cart </a>

thus you can have individual add to cart link.

share|improve this answer
Thanks Mufaddal for the solution – Sarvagya May 20 at 13:17

To me, its inefficient to load the product in its whole when u can get a smaller option.

$this->helper('catalog/output')->productAttribute($_item, nl2br($_item->getDescription()), 'description');

The above would also do the trick and doesn't require loading the whole product object. The processing would be the same as short_description. Yes, this isn't loaded by default but you can just use the attribute by enabling product listing on the attribute you need.

For the record, if you are planning on using larger descriptions you might want to cut them off. I usually do something like this:

<?php echo Mage::helper('core/string')->truncate($this->helper('catalog/output')->productAttribute($_item, nl2br($_item->getDescription()), 'description'),240) ?>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.