Skip to content

Commit 528d847

Browse files
authored
Merge pull request #6857 from magento-tsg/2.4-develop-pr146
[Arrows] Fixes for 2.4 (pr146) (2.4-develop)
2 parents d05f8e9 + 5a8cefa commit 528d847

File tree

7 files changed

+140
-13
lines changed

7 files changed

+140
-13
lines changed

app/code/Magento/Catalog/Block/Product/View.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,21 +177,26 @@ public function getJsonConfig()
177177
{
178178
/* @var $product \Magento\Catalog\Model\Product */
179179
$product = $this->getProduct();
180+
$tierPrices = [];
181+
$priceInfo = $product->getPriceInfo();
182+
$tierPricesList = $priceInfo->getPrice('tier_price')->getTierPriceList();
183+
foreach ($tierPricesList as $tierPrice) {
184+
$tierPriceData = [
185+
'qty' => $tierPrice['price_qty'],
186+
'price' => $tierPrice['website_price'],
187+
];
188+
$tierPrices[] = $tierPriceData;
189+
}
180190

181191
if (!$this->hasOptions()) {
182192
$config = [
183193
'productId' => $product->getId(),
184-
'priceFormat' => $this->_localeFormat->getPriceFormat()
194+
'priceFormat' => $this->_localeFormat->getPriceFormat(),
195+
'tierPrices' => $tierPrices
185196
];
186197
return $this->_jsonEncoder->encode($config);
187198
}
188199

189-
$tierPrices = [];
190-
$priceInfo = $product->getPriceInfo();
191-
$tierPricesList = $priceInfo->getPrice('tier_price')->getTierPriceList();
192-
foreach ($tierPricesList as $tierPrice) {
193-
$tierPrices[] = $tierPrice['price']->getValue() * 1;
194-
}
195200
$config = [
196201
'productId' => (int)$product->getId(),
197202
'priceFormat' => $this->_localeFormat->getPriceFormat(),

app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminAddAdvancedPricingToTheProductExtendedActionGroup.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515

1616
<remove keyForRemoval="selectProductTierPriceCustomerGroupInput"/>
1717
<click selector="{{AdminProductFormAdvancedPricingSection.productTierPriceCustGroupSelect(index)}}" stepKey="clickProductTierPriceCustGroupSelect" after="selectProductTierPriceWebsiteInput"/>
18-
<waitForElement selector="{{AdminProductFormAdvancedPricingSection.productTierPriceGroupOrCatalogOption(groupPrice.customer_group)}}" time="30" stepKey="waitProductTierPriceGroupOrCatalogOption" after="clickProductTierPriceCustGroupSelect"/>
19-
<click selector="{{AdminProductFormAdvancedPricingSection.productTierPriceGroupOrCatalogOption(groupPrice.customer_group)}}" stepKey="clickAllGroupsOption" after="waitProductTierPriceGroupOrCatalogOption"/>
18+
<waitForElement selector="{{AdminProductFormAdvancedPricingSection.customerGroupFilterInputByIndex(index)}}" time="30" stepKey="waitProductTierPriceGroupOrCatalogOption" after="clickProductTierPriceCustGroupSelect"/>
19+
<selectMultipleOptions filterSelector="{{AdminProductFormAdvancedPricingSection.customerGroupFilterInputByIndex(index)}}" optionSelector="{{AdminProductFormAdvancedPricingSection.customerGroupOptionByIndex(index)}}" stepKey="clickAllGroupsOption" after="waitProductTierPriceGroupOrCatalogOption">
20+
<array>['{{groupPrice.customer_group}}']</array>
21+
</selectMultipleOptions>
2022
</actionGroup>
2123
</actionGroups>

app/code/Magento/Catalog/Test/Mftf/Data/TierPriceData.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,18 @@
8686
<data key="price">0.1</data>
8787
<data key="qty">1</data>
8888
</entity>
89+
<entity name="tierPriceForAllGroups" type="data">
90+
<data key="price">80</data>
91+
<data key="price_type">fixed</data>
92+
<data key="website_id">0</data>
93+
<data key="customer_group">ALL GROUPS</data>
94+
<data key="quantity">2</data>
95+
</entity>
96+
<entity name="tierPriceForGeneralGroup" type="data">
97+
<data key="price">70</data>
98+
<data key="price_type">fixed</data>
99+
<data key="website_id">0</data>
100+
<data key="customer_group">General</data>
101+
<data key="quantity">3</data>
102+
</entity>
89103
</entities>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
<element name="msrpType" type="select" selector="//select[@name='product[msrp_display_actual_price_type]']" timeout="30"/>
2727
<element name="save" type="button" selector="#save-button" timeout="30"/>
2828
<element name="modalTitle" type="text" selector="aside.product_form_product_form_advanced_pricing_modal h1.modal-title"/>
29+
<element name="customerGroupFilterInputByIndex" type="input" selector="div[name='product[tier_price][{{rowIndex}}][cust_group]'] div.admin__action-multiselect-search-wrap input" parameterized="true"/>
30+
<element name="customerGroupOptionByIndex" type="text" selector="//div[@name='product[tier_price][{{rowIndex}}][cust_group]']//label[@class='admin__action-multiselect-label']//span" parameterized="true"/>
2931
<!-- Last row tier price elements-->
3032
<element name="lastTierPriceWebsite" type="select" selector="[data-index='tier_price'] table tbody tr.data-row:last-child [name*='[website_id]']"/>
3133
<element name="lastTierPriceCustomerGroup" type="select" selector="[data-index='tier_price'] table tbody tr.data-row:last-child [name*='[cust_group]']"/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="StoreFrontAssertProductFinalPriceChangesDynamicallyOnProductPageWithTierPricesConfiguredTest">
11+
<annotations>
12+
<features value="Catalog"/>
13+
<stories value="Tier price"/>
14+
<title value="Product price is updated according to tier prices when changing product quantity"/>
15+
<description value="Check that price of product will be updated according to tier prices on product page when changing product quantity"/>
16+
<severity value="MAJOR"/>
17+
<testCaseId value="MC-42006"/>
18+
<useCaseId value="MC-41767"/>
19+
<group value="catalog"/>
20+
</annotations>
21+
<before>
22+
<createData entity="SimpleProduct2" stepKey="createSimpleProduct"/>
23+
<createData entity="CustomerEntityOne" stepKey="createCustomer"/>
24+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginToAdmin"/>
25+
</before>
26+
<after>
27+
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/>
28+
<actionGroup ref="StorefrontCustomerLogoutActionGroup" stepKey="customerLogout"/>
29+
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
30+
<actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="amOnProductGridPage"/>
31+
<actionGroup ref="ClearFiltersAdminDataGridActionGroup" stepKey="clearFilterProduct"/>
32+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdmin"/>
33+
</after>
34+
<!--AdminProductPageOpenByIdActionGroup-->
35+
<actionGroup ref="AdminProductPageOpenByIdActionGroup" stepKey="openProductForEdit">
36+
<argument name="productId" value="$createSimpleProduct.id$"/>
37+
</actionGroup>
38+
<actionGroup ref="AdminAddAdvancedPricingToTheProductActionGroup" stepKey="addCustomerGroupPrice">
39+
<argument name="index" value="0"/>
40+
<argument name="groupPrice" value="simpleGroupPrice"/>
41+
</actionGroup>
42+
<actionGroup ref="AdminAddAdvancedPricingToTheProductActionGroup" stepKey="addCustomerGroupPrice2">
43+
<argument name="index" value="1"/>
44+
<argument name="groupPrice" value="tierPriceForAllGroups"/>
45+
</actionGroup>
46+
<actionGroup ref="AdminAddAdvancedPricingToTheProductActionGroup" stepKey="addCustomerGroupPrice3">
47+
<argument name="index" value="2"/>
48+
<argument name="groupPrice" value="tierPriceForGeneralGroup"/>
49+
</actionGroup>
50+
<actionGroup ref="SaveProductFormActionGroup" stepKey="saveSimpleProduct"/>
51+
<actionGroup ref="StorefrontOpenProductPageActionGroup" stepKey="openProductPage">
52+
<argument name="productUrl" value="$createSimpleProduct.custom_attributes[url_key]$"/>
53+
</actionGroup>
54+
<fillField selector="{{StorefrontProductActionSection.quantity}}" userInput="2" stepKey="fillQuantity"/>
55+
<actionGroup ref="StorefrontAssertProductPriceOnProductPageActionGroup" stepKey="seeSimpleProductPriceOnStoreFrontPage">
56+
<argument name="productPrice" value="80"/>
57+
</actionGroup>
58+
<fillField selector="{{StorefrontProductActionSection.quantity}}" userInput="3" stepKey="fillQuantity2"/>
59+
<actionGroup ref="StorefrontAssertProductPriceOnProductPageActionGroup" stepKey="seeSimpleProductPriceOnStoreFrontPage2">
60+
<argument name="productPrice" value="80"/>
61+
</actionGroup>
62+
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginAsCustomer">
63+
<argument name="Customer" value="$createCustomer$" />
64+
</actionGroup>
65+
<actionGroup ref="StorefrontOpenProductPageActionGroup" stepKey="openSimpleProductPage">
66+
<argument name="productUrl" value="$createSimpleProduct.custom_attributes[url_key]$"/>
67+
</actionGroup>
68+
<fillField selector="{{StorefrontProductActionSection.quantity}}" userInput="2" stepKey="fillQuantity3"/>
69+
<actionGroup ref="StorefrontAssertProductPriceOnProductPageActionGroup" stepKey="seeSimpleProductPriceOnStoreFrontPage3">
70+
<argument name="productPrice" value="80"/>
71+
</actionGroup>
72+
<fillField selector="{{StorefrontProductActionSection.quantity}}" userInput="3" stepKey="fillQuantity4"/>
73+
<actionGroup ref="StorefrontAssertProductPriceOnProductPageActionGroup" stepKey="seeSimpleProductPriceOnStoreFrontPage4">
74+
<argument name="productPrice" value="70"/>
75+
</actionGroup>
76+
</test>
77+
</tests>

app/code/Magento/Catalog/view/base/web/js/price-box.js

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ define([
2424

2525
$.widget('mage.priceBox', {
2626
options: globalOptions,
27+
qtyInfo: '#qty',
2728

2829
/**
2930
* Widget initialisation.
@@ -49,6 +50,7 @@ define([
4950

5051
box.on('reloadPrice', this.reloadPrice.bind(this));
5152
box.on('updatePrice', this.onUpdatePrice.bind(this));
53+
$(this.qtyInfo).on('input', this.updateProductTierPrice.bind(this));
5254
box.trigger('price-box-initialized');
5355
},
5456

@@ -101,9 +103,9 @@ define([
101103
priceValue.adjustments = priceValue.adjustments || {};
102104

103105
additionalPrice[priceCode] = additionalPrice[priceCode] || {
104-
'amount': 0,
105-
'adjustments': {}
106-
};
106+
'amount': 0,
107+
'adjustments': {}
108+
};
107109
additionalPrice[priceCode].amount = 0 + (additionalPrice[priceCode].amount || 0) +
108110
priceValue.amount;
109111
_.each(priceValue.adjustments, function (adValue, adCode) {
@@ -214,6 +216,31 @@ define([
214216
if (config && config.prices) {
215217
this.options.prices = config.prices;
216218
}
219+
},
220+
221+
/**
222+
* Updates product final price according to tier prices
223+
*/
224+
updateProductTierPrice: function updateProductTierPrice() {
225+
var productQty = $(this.qtyInfo).val(),
226+
originalPrice = this.options.prices.finalPrice.amount,
227+
tierPrice,
228+
prices,
229+
i;
230+
231+
for (i = 0; i < this.options.priceConfig.tierPrices.length; i++) {
232+
if (productQty >= this.options.priceConfig.tierPrices[i].qty) {
233+
tierPrice = this.options.priceConfig.tierPrices[i].price;
234+
}
235+
}
236+
prices = {
237+
'prices': {
238+
'finalPrice': {
239+
'amount': tierPrice - originalPrice
240+
}
241+
}
242+
};
243+
this.updatePrice(prices);
217244
}
218245
});
219246

app/code/Magento/CatalogInventory/Model/Indexer/Stock/CacheCleaner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ private function getProductIdsForCacheClean(array $productStatusesBefore, array
173173
*/
174174
private function getCategoryIdsByProductIds(array $productIds): array
175175
{
176-
$categoryProductTable = $this->getConnection()->getTableName('catalog_category_product');
176+
$categoryProductTable = $this->resource->getTableName('catalog_category_product');
177177
$select = $this->getConnection()->select()
178178
->from(['catalog_category_product' => $categoryProductTable], ['category_id'])
179179
->where('product_id IN (?)', $productIds);

0 commit comments

Comments
 (0)