1 Comment

get review rating star by product id magento

Magento 2 - Get Current Customer Registry
How to add 'Insert Widget' functionality to category WYSIWYG editors in Magento 2 ?

I need to show rating star on my page.

How to display rating star and review on my page ?

Related Posts

Magento 2 - Get Current Customer Registry
How to add 'Insert Widget' functionality to category WYSIWYG editors in Magento 2 ?

1 Comment on this article

  • User November 12, 2016

    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()
    

    Reply

Add a comment