Skip to content

$product->getRatingSummary() always returns null on products with ratings #4530

@ntoombs19

Description

@ntoombs19

Steps to reproduce

  1. Override this template in a theme 'Magento_Catalog/templates/product/view/review.phtml`
  2. Change the last parameter in the getReviewsSummaryHtml method to false so the method call in the template looks like this
<?php echo $block->getReviewsSummaryHtml($block->getProduct(), false, false)?>

Expected result

  1. A reviews summary will only be displayed for products that have ratings

Actual result

  1. A reviews summary is not displayed for any products; even ones that do have ratings.

Additional Information

  1. Set a break point on the first line of the getReviewsSummary() method in the class \Magento\Review\Block\Product\ReviewRenderer
  2. Load the product detail page of a product that has a rating
  3. Evaluate this expression once your breakpoint is hit $product->getRatingSummary()
  4. It will always evaluate to null even with a product has a rating. Because of this, when $displayIfNoReviews is set to false, the if statement in which this line lives will evaluate to true and an empty string will be returned.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: CatalogFixed in 2.2.xThe issue has been fixed in 2.2 release lineFixed in 2.3.xThe issue has been fixed in 2.3 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is not validGate 1 Failed. Automatic verification of issue format is failedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentbug report

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions