Closed JamesFX2 closed 6 years ago
I do not really get the issue. Could you elaborate and maybe directly propose a solution / do a pull request?
You can submit a review without a rating in Magento. As in just a comment - not 1/5, not 0/5, just no rating whatsoever. For that matter, Magento doesn't let you rate an item as 0/5 (AFAIK).
So you have 2 reviews.
The current code loops through the reviews and increments the $_totalAverageRating variable. In this hypothetical example, $_totalAverageRating is 4.
->getReviewsCount() would return 2.
4 divided by 2 is an AggregateRating of 2. It should be 4. getReviewsCount gives you the number of reviews, not the number of reviews where they included a rating.
Instead of using a method that returns a count of reviews, you'll need to create another variable and increment that when (during the foreach loop) when there's a review with ->getAverageRating($review->getReviewId()) >= 1.
Thanks, now I got it! Working on it.
https://github.com/adampmoss/CreareSEO/blob/master/app/design/frontend/base/default/template/creareseo/product/schema.phtml#L81
You're going to need to increment the number of reviews when you do if ($_averageRating >= 1) on line 69 rather than use the number of reviews. It's throwing off the data!