On the homepage I have a section where I load some products of a certain category. I want to display the review stars of a product below the title if the product has review. Normally I do this with the following code:

<?php if($_product->getRatingSummary()): ?>
    <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
<?php endif; ?>

But that doesn't display the stars, when I delete the IF statement around it, it will display the stars but also for the products that doesn't have reviews...

Did I do something wrong? Maybe a setting somewhere I don't know about?

Magento version:

2 Answers 2


Hope below will helps to you for rating

$_reviews = Mage::getModel('review/review')
foreach($_reviews as $review){
    $product = Mage::getModel('catalog/product')->load($review->getData('entity_pk_value'));
$cumulative = 0;
foreach( $review->getRatingVotes() as $vote ) {
    $cumulative +=$vote->getPercent();

$finalPercentage = 0;
if ($cumulative != 0){
    $finalPercentage = ($cumulative/$j);
  • When I use this I got the same value (percentage) on every product... But I need the value per product.
    – n00bly
    Nov 16, 2017 at 16:29
  • you have to filter product id in review model.
    – Moin Malek
    Nov 17, 2017 at 4:20

How I get a product's star rating. Very easy to implement throughout a site.

<?php $_rating = Mage::getModel('review/review_summary')->load($_product->getId()); ?>

<?php if ($_rating['rating_summary']) {?>
  <div class="ratings">
      <div class="rating-box">
         <div class="rating" style="width:<?php echo $_rating['rating_summary']; ?>%"></div>
<?php } ?>

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.