Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display rating summary in product listing in Magento?

Tags:

magento

review

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 ...

like image 261
Dolly Avatar asked Sep 11 '12 12:09

Dolly


1 Answers

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/>';
    }
?>
like image 130
Hervé Guétin Avatar answered Nov 15 '22 09:11

Hervé Guétin