Skip to content

Commit 38071de

Browse files
Merge remote-tracking branch '36041/fix-for-issue-35881' into comm_voted
2 parents 9eb7157 + f73cea4 commit 38071de

File tree

7 files changed

+211
-56
lines changed

7 files changed

+211
-56
lines changed

app/code/Magento/Catalog/Test/Mftf/Section/StoreFrontRecentProductSection.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111

1212
<section name="StoreFrontRecentlyViewedProductSection">
1313
<element name="ProductName" type="text" selector="//div[@class='products-grid']/ol/li[position()={{position}}]/div/div[@class='product-item-details']/strong/a" parameterized="true"/>
14+
<element name="ProductPrice" type="text" selector=".price-including-tax .price"/>
1415
</section>
15-
</sections>
16+
</sections>

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

Lines changed: 44 additions & 44 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,40 +75,49 @@ public function collect(ProductInterface $product, ProductRenderInterface $produ
8475
$priceInfo = $this->priceInfoFactory->create();
8576
}
8677

87-
$priceInfo->setFinalPrice(
88-
$product
89-
->getPriceInfo()
90-
->getPrice('final_price')
91-
->getAmount()
92-
->getValue()
93-
);
94-
$priceInfo->setMinimalPrice(
95-
$product
78+
if ($product->getTypeId() === Grouped::TYPE_CODE) {
79+
$product = $product
9680
->getPriceInfo()
97-
->getPrice('final_price')
98-
->getMinimalPrice()
99-
->getValue()
100-
);
101-
$priceInfo->setRegularPrice(
102-
$product
103-
->getPriceInfo()
104-
->getPrice('regular_price')
105-
->getAmount()
106-
->getValue()
107-
);
108-
$priceInfo->setMaxPrice(
109-
$product
110-
->getPriceInfo()
111-
->getPrice('final_price')
112-
->getMaximalPrice()
113-
->getValue()
114-
);
81+
->getPrice(FinalPrice::PRICE_CODE)
82+
->getMinProduct();
83+
}
11584

116-
$this->formattedPriceInfoBuilder->build(
117-
$priceInfo,
118-
$productRender->getStoreId(),
119-
$productRender->getCurrencyCode()
120-
);
85+
if ($product !== null) {
86+
$priceInfo->setFinalPrice(
87+
$product
88+
->getPriceInfo()
89+
->getPrice(FinalPrice::PRICE_CODE)
90+
->getAmount()
91+
->getValue()
92+
);
93+
$priceInfo->setMinimalPrice(
94+
$product
95+
->getPriceInfo()
96+
->getPrice(FinalPrice::PRICE_CODE)
97+
->getMinimalPrice()
98+
->getValue()
99+
);
100+
$priceInfo->setRegularPrice(
101+
$product
102+
->getPriceInfo()
103+
->getPrice(RegularPrice::PRICE_CODE)
104+
->getAmount()
105+
->getValue()
106+
);
107+
$priceInfo->setMaxPrice(
108+
$product
109+
->getPriceInfo()
110+
->getPrice(FinalPrice::PRICE_CODE)
111+
->getMaximalPrice()
112+
->getValue()
113+
);
114+
115+
$this->formattedPriceInfoBuilder->build(
116+
$priceInfo,
117+
$productRender->getStoreId(),
118+
$productRender->getCurrencyCode()
119+
);
120+
}
121121

122122
$productRender->setPriceInfo($priceInfo);
123123
}

app/code/Magento/Catalog/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
"magento/module-ui": "*",
3232
"magento/module-url-rewrite": "*",
3333
"magento/module-widget": "*",
34-
"magento/module-wishlist": "*"
34+
"magento/module-wishlist": "*",
35+
"magento/module-grouped-product": "*"
3536
},
3637
"suggest": {
3738
"magento/module-cookie": "*",

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 !== null) ? $minProduct->getPriceInfo()
37+
->getPrice(FinalPrice::PRICE_CODE)
38+
->getAmount() : $minProduct;
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;?>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminAddWidgetToWYSIWYGWithTaxRuleForBundleProductInRecentlyViewedWidgetTest">
12+
<annotations>
13+
<stories value="Create tax rule for grouped product in recently viewed widget"/>
14+
<title value="Create tax rule for grouped product in recently viewed widget"/>
15+
<description value="Create tax rule for grouped product in recently viewed widget"/>
16+
<testCaseId value="AC-6282"/>
17+
<severity value="CRITICAL"/>
18+
</annotations>
19+
<before>
20+
<createData entity="defaultTaxRate" stepKey="initialTaxRate"/>
21+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
22+
<createData entity="_defaultCategory" stepKey="createCategory"/>
23+
<createData entity="SimpleProduct2" stepKey="createFirstSimpleProduct"/>
24+
<createData entity="SimpleProduct2" stepKey="createSecondSimpleProduct"/>
25+
<createData entity="ApiGroupedProduct2" stepKey="createGroupedProduct">
26+
<requiredEntity createDataKey="createCategory"/>
27+
</createData>
28+
<createData entity="OneSimpleProductLink" stepKey="addFirstProduct">
29+
<requiredEntity createDataKey="createGroupedProduct"/>
30+
<requiredEntity createDataKey="createFirstSimpleProduct"/>
31+
</createData>
32+
<updateData entity="OneMoreSimpleProductLink" createDataKey="addFirstProduct" stepKey="addSecondProduct">
33+
<requiredEntity createDataKey="createGroupedProduct"/>
34+
<requiredEntity createDataKey="createSecondSimpleProduct"/>
35+
</updateData>
36+
<!-- Create tax rate for TX -->
37+
<createData entity="TaxRateTexas" stepKey="createTaxRateTX"/>
38+
<!-- Create tax rule -->
39+
<actionGroup ref="AdminCreateTaxRuleWithTwoTaxRatesActionGroup" stepKey="createTaxRule">
40+
<argument name="taxRate" value="$$createTaxRateTX$$"/>
41+
<argument name="taxRate2" value="US_NY_Rate_1"/>
42+
<argument name="taxRule" value="SimpleTaxRule"/>
43+
</actionGroup>
44+
<magentoCLI command="config:set {{CustomDisplayProductPricesInCatalog.path}} {{CustomDisplayProductPricesInCatalog.value}}" stepKey="selectInclAndExlTax"/>
45+
<magentoCLI command="cron:run --group=index" stepKey="runCronReindex"/>
46+
<!-- Create customer -->
47+
<createData entity="Simple_US_Customer_With_Different_Billing_Shipping_Addresses" stepKey="createCustomer"/>
48+
<actionGroup ref="EnabledWYSIWYGActionGroup" stepKey="enableWYSIWYG"/>
49+
<actionGroup ref="CliEnableTinyMCEActionGroup" stepKey="enableTinyMCE" />
50+
</before>
51+
<after>
52+
<actionGroup ref="AdminDeleteTaxRule" stepKey="deleteTaxRule">
53+
<argument name="taxRuleCode" value="{{SimpleTaxRule.code}}" />
54+
</actionGroup>
55+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
56+
<deleteData createDataKey="createFirstSimpleProduct" stepKey="deleteFirstSimpleProduct"/>
57+
<deleteData createDataKey="createSecondSimpleProduct" stepKey="deleteSecondSimpleProduct"/>
58+
<deleteData createDataKey="createGroupedProduct" stepKey="deleteProduct"/>
59+
<deleteData stepKey="deleteTaxRate" createDataKey="initialTaxRate" />
60+
<actionGroup ref="DisabledWYSIWYGActionGroup" stepKey="disableWYSIWYG"/>
61+
<!-- Delete tax rate for UK -->
62+
<deleteData createDataKey="createTaxRateTX" stepKey="deleteTaxRateUK"/>
63+
<!-- Delete customer -->
64+
<magentoCLI command="config:set {{DisplayProductPricesInCatalog.path}} {{DisplayProductPricesInCatalog.value}}" stepKey="selectExlTax"/>
65+
<magentoCron groups="index" stepKey="reindex"/>
66+
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
67+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
68+
</after>
69+
70+
<actionGroup ref="AdminOpenCreateNewCMSPageActionGroup" stepKey="navigateToPage"/>
71+
<fillField selector="{{CmsNewPagePageBasicFieldsSection.pageTitle}}" userInput="{{_defaultCmsPage.title}}" stepKey="fillFieldTitle"/>
72+
<click selector="{{CmsNewPagePageContentSection.header}}" stepKey="clickContentTab" />
73+
<waitForElementVisible selector="{{TinyMCESection.TinyMCE}}" stepKey="waitForTinyMCE"/>
74+
<executeJS function="tinyMCE.activeEditor.setContent('Hello CMS Page!');" stepKey="executeJSFillContent"/>
75+
<seeElement selector="{{TinyMCESection.InsertWidgetIcon}}" stepKey="seeWidgetIcon" />
76+
<click selector="{{TinyMCESection.InsertWidgetIcon}}" stepKey="clickInsertWidgetIcon" />
77+
<waitForPageLoad stepKey="waitForPageLoad" />
78+
<see userInput="Inserting a widget does not create a widget instance." stepKey="seeMessage" />
79+
<!--see Insert Widget button disabled-->
80+
<see selector="{{WidgetSection.InsertWidgetBtnDisabled}}" userInput="Insert Widget" stepKey="seeInsertWidgetDisabled" />
81+
<!--see Cancel button enabled-->
82+
<see selector="{{WidgetSection.CancelBtnEnabled}}" userInput="Cancel" stepKey="seeCancelBtnEnabled" />
83+
<!--Select "Widget Type"-->
84+
<selectOption selector="{{WidgetSection.WidgetType}}" userInput="Recently Viewed Products" stepKey="selectRecentlyViewedProducts" />
85+
<waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskDisappear" />
86+
<!--see Insert Widget button enabled-->
87+
<see selector="{{WidgetSection.InsertWidgetBtnEnabled}}" userInput="Insert Widget" stepKey="seeInsertWidgetEnabled" />
88+
<fillField selector="{{WidgetSection.PageSize}}" userInput="5" stepKey="fillNoOfProductDisplay" />
89+
<selectOption selector="{{WidgetSection.ProductAttribute}}" parameterArray="['Name','Image','Price','Learn More Link']" stepKey="selectSpecifiedOptions"/>
90+
<selectOption selector="{{WidgetSection.ButtonToShow}}" userInput="Add to Cart" stepKey="selectBtnToShow" />
91+
<selectOption selector="{{WidgetSection.WidgetTemplate}}" userInput="Viewed Products Grid Template" stepKey="selectTemplate" />
92+
<actionGroup ref="AdminClickInsertWidgetActionGroup" stepKey="clickInsertWidget"/>
93+
<scrollTo selector="{{CmsNewPagePageSeoSection.header}}" stepKey="scrollToSearchEngineTab" />
94+
<click selector="{{CmsNewPagePageSeoSection.header}}" stepKey="clickExpandSearchEngineOptimisation"/>
95+
<fillField selector="{{CmsNewPagePageSeoSection.urlKey}}" userInput="{{_defaultCmsPage.identifier}}" stepKey="fillFieldUrlKey"/>
96+
<actionGroup ref="SaveCmsPageActionGroup" stepKey="clickSavePage"/>
97+
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginAsCustomer">
98+
<argument name="Customer" value="$$createCustomer$$"/>
99+
</actionGroup>
100+
<!-- Navigate to the product -->
101+
<actionGroup ref="StorefrontOpenProductEntityPageActionGroup" stepKey="openProduct2Page">
102+
<argument name="product" value="$$createGroupedProduct$$"/>
103+
</actionGroup>
104+
<amOnPage url="$$createGroupedProduct.custom_attributes[url_key]$$.html" stepKey="amOnProductPage" />
105+
<waitForPageLoad stepKey="waitForPage" />
106+
<amOnPage url="{{_defaultCmsPage.identifier}}" stepKey="amOnPageTestPage"/>
107+
<waitForPageLoad stepKey="wait5" />
108+
<!--see widget on Storefront-->
109+
<see userInput="Hello CMS Page!" stepKey="seeContent"/>
110+
<waitForPageLoad stepKey="wait6" />
111+
<waitForText userInput="$$createGroupedProduct.name$$" stepKey="waitForProductVisible" />
112+
<grabTextFrom selector="{{StoreFrontRecentlyViewedProductSection.ProductPrice}}" stepKey="grabRelatedProductPosition"/>
113+
<assertStringContainsString stepKey="assertRelatedProductPrice">
114+
<actualResult type="const">$grabRelatedProductPosition</actualResult>
115+
<expectedResult type="string">$133.30</expectedResult>
116+
</assertStringContainsString>
117+
</test>
118+
</tests>
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)