Skip to content

Commit 145e779

Browse files
authored
Merge branch '2.4-develop' into cleanup-cart-totals-processor-default
2 parents adb7574 + 912ceab commit 145e779

File tree

138 files changed

+6273
-5930
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+6273
-5930
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/Test/Mftf/Test/StorefrontCheckCustomOptionPriceDifferentCurrencyTest.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
</annotations>
2121
<before>
2222
<magentoCLI command="config:set {{SetAllowedCurrenciesConfigForUSD.path}} {{SetAllowedCurrenciesConfigForUSD.value}},{{SetAllowedCurrenciesConfigForEUR.value}}" stepKey="setCurrencyAllow"/>
23+
<magentoCLI command="config:set --scope={{SetAllowedCurrenciesConfigForUSD.scope}} --scope-code={{SetAllowedCurrenciesConfigForUSD.scope_code}} {{SetAllowedCurrenciesConfigForUSD.path}} {{SetAllowedCurrenciesConfigForUSD.value}},{{SetAllowedCurrenciesConfigForEUR.value}}" stepKey="setAllowedCurrencyWebsitesForEURandUSD"/>
2324
<createData entity="_defaultCategory" stepKey="createCategory"/>
2425
<createData entity="_defaultProduct" stepKey="createProduct">
2526
<requiredEntity createDataKey="createCategory"/>
@@ -29,6 +30,7 @@
2930
</before>
3031
<after>
3132
<magentoCLI command="config:set {{SetAllowedCurrenciesConfigForUSD.path}} {{SetAllowedCurrenciesConfigForUSD.value}}" stepKey="setCurrencyAllow"/>
33+
<magentoCLI command="config:set --scope={{SetAllowedCurrenciesConfigForUSD.scope}} --scope-code={{SetAllowedCurrenciesConfigForUSD.scope_code}} {{SetAllowedCurrenciesConfigForUSD.path}} {{SetAllowedCurrenciesConfigForUSD.value}}" stepKey="setAllowedCurrencyUSDWebsites"/>
3234
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
3335
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
3436
</after>

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

Lines changed: 31 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) {
@@ -131,6 +133,7 @@ define([
131133
}, this);
132134
}
133135

136+
this.element.trigger('priceUpdated', this.cache.displayPrices);
134137
this.element.trigger('reloadPrice');
135138
},
136139

@@ -214,6 +217,31 @@ define([
214217
if (config && config.prices) {
215218
this.options.prices = config.prices;
216219
}
220+
},
221+
222+
/**
223+
* Updates product final price according to tier prices
224+
*/
225+
updateProductTierPrice: function updateProductTierPrice() {
226+
var productQty = $(this.qtyInfo).val(),
227+
originalPrice = this.options.prices.finalPrice.amount,
228+
tierPrice,
229+
prices,
230+
i;
231+
232+
for (i = 0; i < this.options.priceConfig.tierPrices.length; i++) {
233+
if (productQty >= this.options.priceConfig.tierPrices[i].qty) {
234+
tierPrice = this.options.priceConfig.tierPrices[i].price;
235+
}
236+
}
237+
prices = {
238+
'prices': {
239+
'finalPrice': {
240+
'amount': tierPrice - originalPrice
241+
}
242+
}
243+
};
244+
this.updatePrice(prices);
217245
}
218246
});
219247

app/code/Magento/CatalogGraphQl/DataProvider/Product/LayeredNavigation/AttributeOptionProvider.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public function getOptions(array $optionIds, ?int $storeId, array $attributeCode
6363
'attribute_id' => 'a.attribute_id',
6464
'attribute_code' => 'a.attribute_code',
6565
'attribute_label' => 'a.frontend_label',
66+
'position' => 'attribute_configuration.position'
6667
]
6768
)
6869
->joinLeft(
@@ -72,6 +73,11 @@ public function getOptions(array $optionIds, ?int $storeId, array $attributeCode
7273
'attribute_store_label' => 'attribute_label.value',
7374
]
7475
)
76+
->joinLeft(
77+
['attribute_configuration' => $this->resourceConnection->getTableName('catalog_eav_attribute')],
78+
'a.attribute_id = attribute_configuration.attribute_id',
79+
[]
80+
)
7581
->joinLeft(
7682
['options' => $this->resourceConnection->getTableName('eav_attribute_option')],
7783
'a.attribute_id = options.attribute_id',
@@ -131,6 +137,7 @@ private function formatResult(Select $select): array
131137
'attribute_code' => $option['attribute_code'],
132138
'attribute_label' => $option['attribute_store_label']
133139
? $option['attribute_store_label'] : $option['attribute_label'],
140+
'position' => $option['position'],
134141
'options' => [],
135142
];
136143
}

app/code/Magento/CatalogGraphQl/DataProvider/Product/LayeredNavigation/Builder/Attribute.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,11 @@ public function build(AggregationInterface $aggregation, ?int $storeId): array
8383
$result[$bucketName] = $this->layerFormatter->buildLayer(
8484
$attribute['attribute_label'] ?? $bucketName,
8585
\count($bucket->getValues()),
86-
$attribute['attribute_code'] ?? $bucketName
86+
$attribute['attribute_code'] ?? $bucketName,
87+
isset($attribute['position']) ? $attribute['position'] : null
8788
);
8889

89-
$options = $this->getSortedOptions($bucket,$attribute['options'] ?: []);
90+
$options = $this->getSortedOptions($bucket, isset($attribute['options']) ? $attribute['options'] : []);
9091
foreach ($options as $option) {
9192
$result[$bucketName]['options'][] = $this->layerFormatter->buildItem(
9293
$option['label'],

app/code/Magento/CatalogGraphQl/DataProvider/Product/LayeredNavigation/Formatter/LayerFormatter.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@ class LayerFormatter
1818
* @param string $layerName
1919
* @param string $itemsCount
2020
* @param string $requestName
21+
* @param int $position
2122
* @return array
2223
*/
23-
public function buildLayer($layerName, $itemsCount, $requestName): array
24+
public function buildLayer($layerName, $itemsCount, $requestName, $position = null): array
2425
{
2526
return [
2627
'label' => $layerName,
2728
'count' => $itemsCount,
28-
'attribute_code' => $requestName
29+
'attribute_code' => $requestName,
30+
'position' => isset($position) ? (int)$position : null
2931
];
3032
}
3133

0 commit comments

Comments
 (0)