Whilst working on a Magento webshop I was asked to show the ratings and several custom attributes for the related products. Sadly I found out that the data collection Magento fetches by default for related products is limited to the data they want to show in their default theme so I had to find another way.
As it turns out this is pretty easy but poorly documented. Basically I just added the following within the foreach loop in ‘/app/design/frontend/default/templatename/template/catalog/product/list/related.phtml’.
$model = Mage::getModel('catalog/product'); $model->load($_item->getId());
Now instead of the default fields I can easily get all the other product data too with some simple functions like:
<?php // For the ratings echo $this->getReviewsSummaryHtml($model); // For a custom dropdown attribute named 'brand' echo $model->getAttributeText('brand'); ?>
Of course this also works in every other loop, as long as you have the product ID you can fetch all the data you want.
Hi
I wonder if can help with a Magento question?
Do you know how to add an image of the product to the order email template and a product link back to its product page on the Magento site? I can’t find any info on this, not sure if can be done, any help would be great.
Thanks
Hi,
I need some help for creating new API for magento. The problem is where to store the xml and php file and naming of the php class ? So can you show me sample for this ?
Hi Shameem,
This can differ per version of Magento, which version are you using?
Cheers,
Luc
Hi ,
Thanks for your reply,
I am using magento community edition 1.7.0.1.
Shameem