Skip to content

Commit 91bb6ee

Browse files
committed
Merge branch '2.4-develop' of https://github.com/magento/magento2ce into TANGO_PR-05-11-2021_24
2 parents bb4f457 + 912ceab commit 91bb6ee

File tree

107 files changed

+5231
-1001
lines changed

Some content is hidden

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

107 files changed

+5231
-1001
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/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);

app/code/Magento/Checkout/Model/PaymentInformationManagement.php

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Checkout\Api\PaymentSavingRateLimiterInterface;
1212
use Magento\Framework\App\ObjectManager;
1313
use Magento\Framework\Exception\CouldNotSaveException;
14+
use Magento\Quote\Api\CartRepositoryInterface;
1415

1516
/**
1617
* Payment information management service.
@@ -51,7 +52,7 @@ class PaymentInformationManagement implements \Magento\Checkout\Api\PaymentInfor
5152
private $logger;
5253

5354
/**
54-
* @var \Magento\Quote\Api\CartRepositoryInterface
55+
* @var CartRepositoryInterface
5556
*/
5657
private $cartRepository;
5758

@@ -78,6 +79,7 @@ class PaymentInformationManagement implements \Magento\Checkout\Api\PaymentInfor
7879
* @param \Magento\Quote\Api\CartTotalRepositoryInterface $cartTotalsRepository
7980
* @param PaymentProcessingRateLimiterInterface|null $paymentRateLimiter
8081
* @param PaymentSavingRateLimiterInterface|null $saveRateLimiter
82+
* @param CartRepositoryInterface|null $cartRepository
8183
* @codeCoverageIgnore
8284
*/
8385
public function __construct(
@@ -87,7 +89,8 @@ public function __construct(
8789
\Magento\Checkout\Model\PaymentDetailsFactory $paymentDetailsFactory,
8890
\Magento\Quote\Api\CartTotalRepositoryInterface $cartTotalsRepository,
8991
?PaymentProcessingRateLimiterInterface $paymentRateLimiter = null,
90-
?PaymentSavingRateLimiterInterface $saveRateLimiter = null
92+
?PaymentSavingRateLimiterInterface $saveRateLimiter = null,
93+
?CartRepositoryInterface $cartRepository = null
9194
) {
9295
$this->billingAddressManagement = $billingAddressManagement;
9396
$this->paymentMethodManagement = $paymentMethodManagement;
@@ -98,6 +101,8 @@ public function __construct(
98101
?? ObjectManager::getInstance()->get(PaymentProcessingRateLimiterInterface::class);
99102
$this->saveRateLimiter = $saveRateLimiter
100103
?? ObjectManager::getInstance()->get(PaymentSavingRateLimiterInterface::class);
104+
$this->cartRepository = $cartRepository
105+
?? ObjectManager::getInstance()->get(CartRepositoryInterface::class);
101106
}
102107

103108
/**
@@ -154,10 +159,8 @@ public function savePaymentInformation(
154159
}
155160

156161
if ($billingAddress) {
157-
/** @var \Magento\Quote\Api\CartRepositoryInterface $quoteRepository */
158-
$quoteRepository = $this->getCartRepository();
159162
/** @var \Magento\Quote\Model\Quote $quote */
160-
$quote = $quoteRepository->getActive($cartId);
163+
$quote = $this->cartRepository->getActive($cartId);
161164
$customerId = $quote->getBillingAddress()
162165
->getCustomerId();
163166
if (!$billingAddress->getCustomerId() && $customerId) {
@@ -204,19 +207,4 @@ private function getLogger()
204207
}
205208
return $this->logger;
206209
}
207-
208-
/**
209-
* Get Cart repository
210-
*
211-
* @return \Magento\Quote\Api\CartRepositoryInterface
212-
* @deprecated 100.2.0
213-
*/
214-
private function getCartRepository()
215-
{
216-
if (!$this->cartRepository) {
217-
$this->cartRepository = ObjectManager::getInstance()
218-
->get(\Magento\Quote\Api\CartRepositoryInterface::class);
219-
}
220-
return $this->cartRepository;
221-
}
222210
}

app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithInvalidDomainLinkUrlTest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<title value="Create Downloadable Product with invalid domain link url"/>
1515
<description value="Admin should not be able to create downloadable product with invalid domain link url"/>
1616
<severity value="CRITICAL"/>
17-
<testCaseId value="MC-18282"/>
17+
<testCaseId value="MC-28757"/>
1818
<useCaseId value="MC-17700"/>
1919
<group value="Downloadable"/>
2020
</annotations>
@@ -40,6 +40,7 @@
4040
<actionGroup ref="SaveProductFormActionGroup" stepKey="saveProductAfterAddingDomainToAllowlist" after="addDownloadableProductLinkAgain" />
4141
<scrollTo selector="{{StorefrontDownloadableProductSection.downloadableLinkByTitle(downloadableLink.title)}}" stepKey="scrollToLinks"/>
4242
<click selector="{{StorefrontDownloadableProductSection.downloadableLinkByTitle(downloadableLink.title)}}" stepKey="selectProductLink"/>
43+
<scrollTo selector="{{StorefrontProductInfoMainSection.AddToCart}}" before="addProductToCart" stepKey="scrollToAddToCart"/>
4344
<see selector="{{CheckoutCartProductSection.ProductPriceByName(DownloadableProduct.name)}}" userInput="$52.99" stepKey="assertProductPriceInCart"/>
4445
</test>
4546
</tests>

0 commit comments

Comments
 (0)