Question

I need to show rating star on my page.

How to display rating star and review on my page ?

Was it helpful?

Solution

You can get rating summary of product by below code:

    <?php echo $RatingOb=Mage::getModel('rating/rating')->getEntitySummary($_product->getId());
     $ratings=$RatingOb->getSum()/$RatingOb->getCount();
    ?>
    <?php if($ratings): ?>
    <div class="ratings">
        <div class="rating-box">
            <div class="rating" style="width:<?php echo $ratings; ?>%"></div>
        </div>
    </div>
<?php endif; ?>

and need to css and image in css file / images file at Skin folder:

/* rating star */
.ratings { font-size:11px; line-height:1.25; margin:7px 0; }
.ratings strong { float:left; margin:1px 3px 0 0; }
.rating-box { width:69px; height:13px; font-size:0; line-height:0; background:url(../images/bkg_rating.gif) 0 0 repeat-x; text-indent:-999em; overflow:hidden; }
.rating-box .rating { float:left; height:13px; background:url(../images/bkg_rating.gif) 0 100% repeat-x; }
.ratings .rating-box { float:left; margin-right:3px; }

Using Block call

<?php if($_product->getRatingSummary()): ?>
<?php echo $this->getLayout()->createBlock('review/helper')->getSummaryHtml($_product, 'short'); ?>
<?php endif; ?>

Also check review/helper/summary_short.phtml is default or change

Also you can product rating by

$_product->getRatingSummary()->getRatingSummary()
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top