Skip to content

Commit ad0868b

Browse files
committed
MC-40116: Product review rating stars are incorrectly calculated on Review Details in My Account
- Adding correct div for rating star rendering
1 parent fadbf69 commit ad0868b

File tree

2 files changed

+8
-5
lines changed
  • app/code/Magento/Review/view/frontend/templates/customer
  • dev/tests/integration/testsuite/Magento/Review/Block/Customer

2 files changed

+8
-5
lines changed

app/code/Magento/Review/view/frontend/templates/customer/view.phtml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,22 @@ $product = $block->getProductData();
3838
<?php foreach ($block->getRating() as $_rating): ?>
3939
<?php if ($_rating->getPercent()): ?>
4040
<?php $rating = ceil($_rating->getPercent()) ?>
41+
<?php $ratingId = $_rating->getRatingId() ?>
4142
<div class="rating-summary item">
4243
<span class="rating-label">
4344
<span><?= $block->escapeHtml($_rating->getRatingCode()) ?></span>
4445
</span>
45-
<div class="rating-result" title="<?= /* @noEscape */ $rating ?>%">
46+
<div class="rating-result"
47+
id="rating-div-<?= $block->escapeHtml($ratingId) ?>"
48+
title="<?= /* @noEscape */ $rating ?>%">
4649
<span>
4750
<span><?= /* @noEscape */ $rating ?>%</span>
4851
</span>
4952
</div>
5053
<?= /* @noEscape */ $secureRenderer->renderStyleAsTag(
5154
"width:" . /* @noEscape */ $rating . "%",
52-
'div.rating-result>span:first-child'
55+
'div#rating-div-'.$_rating->getRatingId().
56+
'>span:first-child'
5357
) ?>
5458
</div>
5559
<?php endif; ?>

dev/tests/integration/testsuite/Magento/Review/Block/Customer/ViewTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,12 @@ public function testCustomerProductReviewBlock(): void
8181
$ratings = $this->block->getRating();
8282
$this->assertCount(2, $ratings);
8383
foreach ($ratings as $rating) {
84+
$this->assertNotEmpty($rating->getRatingId());
8485
$this->assertEquals(
8586
1,
8687
Xpath::getElementsCountForXpath(
8788
sprintf(
88-
"//div[contains(@class, 'rating-summary')]//span[contains(text(), '%s')]"
89-
. "/../..//span[contains(text(), '%s%%')]",
90-
$rating->getRatingCode(),
89+
"//div[contains(@id, 'rating-div-".$rating->getRatingId()."')]//span[contains(text(), '%s')]",
9190
$rating->getPercent()
9291
),
9392
$blockHtml

0 commit comments

Comments
 (0)