How to display rating summary in product listing in Magento?

Dolly picture Dolly · Sep 11, 2012 · Viewed 12.7k times · Source

I am using this url: http://xhtmlandcsshelp.blogspot.in/2010/12/get-products-from-particular-category.html

i need to display particular category id's product on home page

So I used that url, i have added,

$model->load($_prdIds);
$pname = $model->getName();

But rating summary stars how do I display? Can anyone help me please?

Thanks in advance ...

Answer

Hervé Guétin picture Hervé Guétin · Sep 11, 2012

Tested and working on Magento 1.7.0.1


Reviews on homepage


<?php
    /**
     * Instanciate reviews helper
     */
    $this->_reviewsHelperBlock = $this->getLayout()->createBlock('review/helper');

    /**
     * Get products for your category
     */
    $products = Mage::getModel('catalog/category')->load(YOUR_CATEGORY_ID)->getProductCollection();

    /**
     * Loop thru products
     */
    foreach($products as $product) {
        $product = Mage::getModel('catalog/product')->load($product->getId());
        echo $product->getName();

        /**
         * Display review summary with stars.
         * If correctly configured in back-office: Catalog > Reviews and Ratings > Manage Ratings
         */
        echo $this->_reviewsHelperBlock->getSummaryHtml($product, false, false);

        echo '<hr/>';
    }
?>