products list Currently, on the list of products starts is displayed only when someone adds reviews. I need to display the stars and message to leave review and rating. In template found that it should've been displayed "Be the first to review this product",but it's not.

Here is summary_short.phtml

<?php if ($this->getReviewsCount()): ?>
    <div class="ratings">
        <?php if ($this->getRatingSummary()):?>
            <div class="rating-box">
                <div class="rating" style="width:<?php echo $this->getRatingSummary() ?>%"></div>
        <?php endif;?>
        <span class="amount"><?php echo $this->__('%d Review(s)', $this->getReviewsCount()) ?></span>
<?php elseif ($this->getDisplayIfEmpty()): ?>
    <p class="no-rating"><?php echo $this->__('Be the first to review this product') ?></p>
<?php endif; ?>

And corresponding part of rating block in list.phtml

                    <div class="item-content">
                        if ($this->getChild('name.after')) {
                            $_nameAfterChildren = $this->getChild('name.after')->getSortedChildren();
                            foreach ($_nameAfterChildren as $_nameAfterChildName) {
                                $_nameAfterChild = $this->getChild('name.after')->getChild($_nameAfterChildName);
                                echo $_nameAfterChild->toHtml();
                        <a href="<?php echo "{$this->escapeUrl($product->getProductUrl())}#customer-reviews"; ?>">
                            <?php if ($product->getRatingSummary()): ?>
                                <?php if ($gc['display_rating'] == 1): //Display on hover ?>
                                    <div class="display-onhover ratings-wrapper">
                                        <?php echo $this->getReviewsSummaryHtml($product, 'short'); ?>
                                <?php elseif ($gc['display_rating'] == 2): //Always display ?>
                                    <?php echo $this->getReviewsSummaryHtml($product, 'short'); ?>
                                <?php endif; ?>
                            <?php endif; ?>

  • check this link --- stackoverflow.com/questions/12370028/… Jul 12 '20 at 4:24
  • @MohitPatel Tried this code, it just shows stars and ratings only for products which has reviews. But doesn't shows stars for products with no reviews as I want.
    – big ben
    Jul 13 '20 at 10:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.