<?php echo $block->getReviewsSummaryHtml($block->getProduct(), false, false)?>
A reviews summary will only be displayed for products that have ratings
A reviews summary is not displayed for any products; even ones that do have ratings.
Set a break point on the first line of the getReviewsSummary() method in the class \Magento\Review\Block\Product\ReviewRenderer
$product->getRatingSummary()Hello @ntoombs19 ! I cannot reproduce this issue by your steps. Do you still have this issue? Which code version do you use?
I'm having the same issue. When the third parameter to getReviewsSummaryHtml is set to false, even if the product has reviews, the summary stars are not shown.
I think @ntoombs19 made a mistake in his steps to reproduce. It should read:
Change the last parameter in the getReviewsSummaryHtml method to _false_
The expectation is that when $displayIfNoReviews is false, the message "Be the first to write a review", is suppressed. When there _are_ reviews, the stars should display as normal.
The reality is that when $displayIfNoReviews is false, the message is suppressed, but so are the stars, even when the product has ratings.
The reason is, as @ntoombs19 points out, is that $product->getRatingSummary() always returns null.
In an ideal world, we'd also get rid of the boolean with the negative name, which would prevent the @ntoombs19 error and my three hundred edits of this comment for the sake of clarity and fixing my own mistakes ;)
@vduglued
Thank you for clarification on this issue!
@ntoombs19
Is it make sense for you?
@andimov Yes that makes sense. I've corrected my mistake.
@vduglued Thank you for finding my error. It is indeed very confusing to have negative boolean variable names.
@ntoombs19
Ok, thank you! So I'll close this issue as not a bug. Feel free to reopen if it needed.
I think the bug is valid. The error was in reporting it in a slightly confusing way, but the bug is definitely real...
@andimov I think you misunderstood. I made a mistake in my initial bug report saying to change the last parameter to true when I meant to say false. This is indeed a bug and it needs to be resolved. This issue needs to be reopened and my updated bug report needs to be reproduced and confirmed as a bug and then fixed.
@ntoombs19 @vduglued
Ok!
"Hot fix" would be applying the following diff.
I.e. just loading the rating summary if it's "falsy" at the time of checking… There may be better options, though.
Will create a pull request eventually…
--- a/app/code/Magento/Review/Block/Product/ReviewRenderer.php
+++ b/app/code/Magento/Review/Block/Product/ReviewRenderer.php
@@ -57,6 +57,10 @@ class ReviewRenderer extends \Magento\Fr
$templateType = self::DEFAULT_VIEW,
$displayIfNoReviews = false
) {
+ if (!$product->getRatingSummary()) {
+ $this->_reviewFactory->create()->getEntitySummary($product, $this->_storeManager->getStore()->getId());
+ }
+
if (!$product->getRatingSummary() && !$displayIfNoReviews) {
return '';
}
@@ -67,10 +71,6 @@ class ReviewRenderer extends \Magento\Fr
$this->setTemplate($this->_availableTemplates[$templateType]);
$this->setDisplayIfEmpty($displayIfNoReviews);
-
- if (!$product->getRatingSummary()) {
- $this->_reviewFactory->create()->getEntitySummary($product, $this->_storeManager->getStore()->getId());
- }
$this->setProduct($product);
return $this->toHtml();
Internal ticket to track issue progress: MAGETWO-70758
@ntoombs19, thank you for your report.
The issue is already fixed in develop branch
But we will consider to backport the fix to patch releases
Hi @ntoombs19 the issue has been fixed in 2.2-develop branch and will be available with release 2.2.1 soon