Skip to content

Commit 96dc100

Browse files
committed
Merge branch '2.4-develop' of https://github.com/magento/magento2ce into MC-42243
2 parents f6f1e7a + ad492ab commit 96dc100

File tree

38 files changed

+959
-68
lines changed

38 files changed

+959
-68
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);

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/Quote/Model/QuoteManagement.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,15 @@ protected function submitQuote(QuoteEntity $quote, $orderData = [])
553553
$order->setCustomerFirstname($quote->getCustomerFirstname());
554554
$order->setCustomerMiddlename($quote->getCustomerMiddlename());
555555
$order->setCustomerLastname($quote->getCustomerLastname());
556+
557+
if ($quote->getOrigOrderId()) {
558+
$order->setEntityId($quote->getOrigOrderId());
559+
}
560+
561+
if ($quote->getReservedOrderId()) {
562+
$order->setIncrementId($quote->getReservedOrderId());
563+
}
564+
556565
$this->submitQuoteValidator->validateOrder($order);
557566

558567
$this->eventManager->dispatch(

app/code/Magento/Sales/Model/OrderRepository.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,13 @@ private function setPaymentAdditionalInfo(OrderInterface $order): void
186186
if ($extensionAttributes === null) {
187187
$extensionAttributes = $this->orderExtensionFactory->create();
188188
}
189-
$paymentAdditionalInformation = $order->getPayment()->getAdditionalInformation();
189+
190+
$paymentAdditionalInformation = [];
191+
$payment = $order->getPayment();
192+
193+
if ($payment) {
194+
$paymentAdditionalInformation = $payment->getAdditionalInformation();
195+
}
190196

191197
$objects = [];
192198
foreach ($paymentAdditionalInformation as $key => $value) {

0 commit comments

Comments
 (0)