2

I need to show rating star on my page.

How to display rating star and review on my page ?

1 Answer 1

8

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()
4
  • can't get Star ,,,,,, Output is 1 Review(s) | Add Your Review Feb 26, 2015 at 10:10
  • cheeck again................
    – Amit Bera
    Feb 26, 2015 at 10:21
  • 1
    i got solution problem with css i need review like this Overall 4.9 out of 5 base on 89 customers Feb 26, 2015 at 12:31
  • 1
    @AmitBera i have different module that view the product details.Is there any idea to show the rating block on that page too?
    – Mujahidh
    Apr 26, 2016 at 12:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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