Skip to content

Commit 0bb2e31

Browse files
committed
#35881: Final Price for grouped products does not include tax in the Recently Viewed Widget and Meta price
- fixed Viewed Widget for Grouped Product - Fixed price in <meta property="product:price:amount" for Grouped Product - clear constants that are not used - replace PRICE_CODE through a constant
1 parent 1e46eec commit 0bb2e31

File tree

4 files changed

+59
-26
lines changed

4 files changed

+59
-26
lines changed

app/code/Magento/Catalog/Ui/DataProvider/Product/Listing/Collector/Price.php

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@
1111
use Magento\Catalog\Api\Data\ProductRender\PriceInfoInterfaceFactory;
1212
use Magento\Catalog\Api\Data\ProductRenderInterface;
1313
use Magento\Catalog\Model\ProductRender\FormattedPriceInfoBuilder;
14+
use Magento\Catalog\Pricing\Price\FinalPrice;
15+
use Magento\Catalog\Pricing\Price\RegularPrice;
1416
use Magento\Catalog\Ui\DataProvider\Product\ProductRenderCollectorInterface;
1517
use Magento\Framework\Pricing\PriceCurrencyInterface;
18+
use Magento\GroupedProduct\Model\Product\Type\Grouped;
1619

1720
/**
1821
* Collect information about base prices of products
@@ -22,18 +25,6 @@
2225
*/
2326
class Price implements ProductRenderCollectorInterface
2427
{
25-
/** FInal Price key */
26-
const KEY_FINAL_PRICE = "final_price";
27-
28-
/** Minimal Price key */
29-
const KEY_MINIMAL_PRICE = "minimal_price";
30-
31-
/** Regular Price key */
32-
const KEY_REGULAR_PRICE = "regular_price";
33-
34-
/** Max Price key */
35-
const KEY_MAX_PRICE = "max_price";
36-
3728
/**
3829
* @var PriceCurrencyInterface
3930
*/
@@ -84,31 +75,38 @@ public function collect(ProductInterface $product, ProductRenderInterface $produ
8475
$priceInfo = $this->priceInfoFactory->create();
8576
}
8677

78+
if ($product->getTypeId() === Grouped::TYPE_CODE) {
79+
$product = $product
80+
->getPriceInfo()
81+
->getPrice(FinalPrice::PRICE_CODE)
82+
->getMinProduct();
83+
}
84+
8785
$priceInfo->setFinalPrice(
8886
$product
8987
->getPriceInfo()
90-
->getPrice('final_price')
88+
->getPrice(FinalPrice::PRICE_CODE)
9189
->getAmount()
9290
->getValue()
9391
);
9492
$priceInfo->setMinimalPrice(
9593
$product
9694
->getPriceInfo()
97-
->getPrice('final_price')
95+
->getPrice(FinalPrice::PRICE_CODE)
9896
->getMinimalPrice()
9997
->getValue()
10098
);
10199
$priceInfo->setRegularPrice(
102100
$product
103101
->getPriceInfo()
104-
->getPrice('regular_price')
102+
->getPrice(RegularPrice::PRICE_CODE)
105103
->getAmount()
106104
->getValue()
107105
);
108106
$priceInfo->setMaxPrice(
109107
$product
110108
->getPriceInfo()
111-
->getPrice('final_price')
109+
->getPrice(FinalPrice::PRICE_CODE)
112110
->getMaximalPrice()
113111
->getValue()
114112
);

app/code/Magento/Catalog/view/frontend/templates/product/view/opengraph/general.phtml

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,47 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
/** @var $block \Magento\Catalog\Block\Product\View */
7+
use Magento\Catalog\Block\Product\View;
8+
use Magento\Catalog\Model\Product;
9+
use Magento\Catalog\Pricing\Price\FinalPrice;
10+
use Magento\Framework\Escaper;
11+
use Magento\GroupedProduct\Model\Product\Type\Grouped;
12+
13+
/**
14+
* @var View $block
15+
* @var Escaper $escaper
16+
*/
817
?>
918

1019
<meta property="og:type" content="product" />
1120
<meta property="og:title"
12-
content="<?= $block->escapeHtmlAttr($block->stripTags($block->getProduct()->getName())) ?>" />
21+
content="<?= $escaper->escapeHtmlAttr($block->stripTags($block->getProduct()->getName())) ?>" />
1322
<meta property="og:image"
14-
content="<?= $block->escapeUrl($block->getImage($block->getProduct(), 'product_base_image')->getImageUrl()) ?>" />
23+
content="<?= $escaper->escapeUrl($block->getImage($block->getProduct(), 'product_base_image')->getImageUrl()) ?>"
24+
/>
1525
<meta property="og:description"
16-
content="<?= $block->escapeHtmlAttr($block->stripTags($block->getProduct()->getShortDescription())) ?>" />
26+
content="<?= $escaper->escapeHtmlAttr($block->stripTags($block->getProduct()->getShortDescription())) ?>" />
1727
<meta property="og:url" content="<?= $block->escapeUrl($block->getProduct()->getProductUrl()) ?>" />
18-
<?php if ($priceAmount = $block->getProduct()
19-
->getPriceInfo()
20-
->getPrice(\Magento\Catalog\Pricing\Price\FinalPrice::PRICE_CODE)
21-
->getAmount()):?>
22-
<meta property="product:price:amount" content="<?= $block->escapeHtmlAttr($priceAmount) ?>"/>
23-
<?= $block->getChildHtml('meta.currency') ?>
28+
<?php
29+
if ($block->getProduct()->getTypeId() === Grouped::TYPE_CODE):
30+
/** @var Product $minProduct */
31+
$minProduct = $block->getProduct()
32+
->getPriceInfo()
33+
->getPrice(FinalPrice::PRICE_CODE)
34+
->getMinProduct();
35+
36+
$priceAmount = $minProduct->getPriceInfo()
37+
->getPrice(FinalPrice::PRICE_CODE)
38+
->getAmount();
39+
else:
40+
$priceAmount = $block->getProduct()
41+
->getPriceInfo()
42+
->getPrice(FinalPrice::PRICE_CODE)
43+
->getAmount();
44+
endif;
45+
?>
46+
47+
<?php if ($priceAmount !== null): ?>
48+
<meta property="product:price:amount" content="<?= $block->escapeHtmlAttr($priceAmount) ?>"/>
49+
<?= $block->getChildHtml('meta.currency') ?>
2450
<?php endif;?>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<!--
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
-->

app/code/Magento/GroupedProduct/view/frontend/ui_component/widget_recently_viewed.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
<item name="regular_price" xsi:type="array">
1818
<item name="bodyTmpl" xsi:type="string">Magento_GroupedProduct/product/price/regular_price</item>
1919
</item>
20+
<item name="special_price" xsi:type="array">
21+
<item name="bodyTmpl" xsi:type="string">Magento_GroupedProduct/product/price/special_price</item>
22+
</item>
2023
<item name="minimal_price" xsi:type="array">
2124
<item name="label" xsi:type="string" translate="true">Starting at</item>
2225
<item name="bodyTmpl" xsi:type="string">Magento_GroupedProduct/product/price/minimal_price</item>

0 commit comments

Comments
 (0)