Skip to content

Commit 771173f

Browse files
committed
Merge remote-tracking branch 'mainline/2.4-develop' into ACP2E-2102
2 parents 997b8c9 + 3e685e0 commit 771173f

File tree

65 files changed

+1950
-61
lines changed

Some content is hidden

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

65 files changed

+1950
-61
lines changed

app/code/Magento/Catalog/Model/Product/Price/BasePriceStorage.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,11 @@ public function update(array $prices)
157157
{
158158
$prices = $this->retrieveValidPrices($prices);
159159
$formattedPrices = [];
160+
$productIds = [];
160161

161162
foreach ($prices as $price) {
162163
$ids = array_keys($this->productIdLocator->retrieveProductIdsBySkus([$price->getSku()])[$price->getSku()]);
164+
$productIds[] = $ids[key($ids)];
163165
foreach ($ids as $id) {
164166
$formattedPrices[] = [
165167
'store_id' => $price->getStoreId(),
@@ -182,6 +184,7 @@ public function update(array $prices)
182184
}
183185

184186
$this->getPricePersistence()->update($formattedPrices);
187+
$this->getPricePersistence()->updateLastUpdatedAt($productIds);
185188

186189
return $this->validationResult->getFailedItems();
187190
}

app/code/Magento/Catalog/Model/Product/Price/PricePersistence.php

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,15 @@
1010
use Magento\Catalog\Api\ProductAttributeRepositoryInterface;
1111
use Magento\Catalog\Model\ProductIdLocatorInterface;
1212
use Magento\Catalog\Model\ResourceModel\Attribute;
13+
use Magento\Framework\App\ObjectManager;
1314
use Magento\Framework\EntityManager\MetadataPool;
1415
use Magento\Framework\Exception\CouldNotDeleteException;
1516
use Magento\Framework\Exception\CouldNotSaveException;
17+
use Magento\Framework\Stdlib\DateTime\DateTime;
1618

1719
/**
1820
* Class responsibly for persistence of prices.
21+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1922
*/
2023
class PricePersistence
2124
{
@@ -42,33 +45,40 @@ class PricePersistence
4245
private $productIdLocator;
4346

4447
/**
45-
* Metadata pool.
48+
* Metadata pool property to get a metadata.
4649
*
4750
* @var MetadataPool
4851
*/
4952
private $metadataPool;
5053

5154
/**
52-
* Attribute code.
55+
* Attribute code attribute to get the attribute id.
5356
*
5457
* @var string
5558
*/
5659
private $attributeCode;
5760

5861
/**
59-
* Attribute ID.
62+
* Attribute ID property to store the attribute id.
6063
*
6164
* @var int
6265
*/
6366
private $attributeId;
6467

6568
/**
66-
* Items per operation.
69+
* Items per operation to chunk the array in a batch.
6770
*
6871
* @var int
6972
*/
7073
private $itemsPerOperation = 500;
7174

75+
/**
76+
* Date time property to get the gm date.
77+
*
78+
* @var DateTime
79+
*/
80+
private $dateTime;
81+
7282
/**
7383
* PricePersistence constructor.
7484
*
@@ -77,19 +87,23 @@ class PricePersistence
7787
* @param ProductIdLocatorInterface $productIdLocator
7888
* @param MetadataPool $metadataPool
7989
* @param string $attributeCode
90+
* @param DateTime|null $dateTime
8091
*/
8192
public function __construct(
8293
Attribute $attributeResource,
8394
ProductAttributeRepositoryInterface $attributeRepository,
8495
ProductIdLocatorInterface $productIdLocator,
8596
MetadataPool $metadataPool,
86-
$attributeCode = ''
97+
$attributeCode = '',
98+
?DateTime $dateTime = null
8799
) {
88100
$this->attributeResource = $attributeResource;
89101
$this->attributeRepository = $attributeRepository;
90102
$this->attributeCode = $attributeCode;
91103
$this->productIdLocator = $productIdLocator;
92104
$this->metadataPool = $metadataPool;
105+
$this->dateTime = $dateTime ?: ObjectManager::getInstance()
106+
->get(DateTime::class);
93107
}
94108

95109
/**
@@ -233,4 +247,27 @@ public function getEntityLinkField()
233247
return $this->metadataPool->getMetadata(ProductInterface::class)
234248
->getLinkField();
235249
}
250+
251+
/**
252+
* Update last updated date.
253+
*
254+
* @param array $productIds
255+
* @return void
256+
* @throws CouldNotSaveException
257+
*/
258+
public function updateLastUpdatedAt(array $productIds): void
259+
{
260+
try {
261+
$this->attributeResource->getConnection()->update(
262+
$this->attributeResource->getTable('catalog_product_entity'),
263+
[ProductInterface::UPDATED_AT => $this->dateTime->gmtDate()],
264+
[$this->getEntityLinkField(). ' IN(?)' => $productIds]
265+
);
266+
} catch (\Exception $e) {
267+
throw new CouldNotSaveException(
268+
__("The attribute can't be saved."),
269+
$e
270+
);
271+
}
272+
}
236273
}

app/code/Magento/Catalog/Model/Product/Price/Validation/TierPriceValidator.php

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
use Magento\Framework\Exception\LocalizedException;
1717
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1818
use Magento\Store\Api\WebsiteRepositoryInterface;
19+
use Magento\Framework\App\ObjectManager;
20+
use Magento\Framework\App\Config\ScopeConfigInterface;
21+
use Magento\Catalog\Helper\Data;
22+
use Magento\Store\Model\ScopeInterface;
23+
use Magento\Framework\Exception\NoSuchEntityException;
1924

2025
/**
2126
* Validate Tier Price and check duplication
@@ -91,6 +96,11 @@ class TierPriceValidator implements ResetAfterRequestInterface
9196
*/
9297
private $productsCacheBySku = [];
9398

99+
/**
100+
* @var ScopeConfigInterface
101+
*/
102+
private $scopeConfig;
103+
94104
/**
95105
* TierPriceValidator constructor.
96106
*
@@ -103,17 +113,20 @@ class TierPriceValidator implements ResetAfterRequestInterface
103113
* @param InvalidSkuProcessor $invalidSkuProcessor
104114
* @param ProductRepositoryInterface $productRepository
105115
* @param array $allowedProductTypes [optional]
116+
* @param ScopeConfigInterface|null $scopeConfig
117+
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
106118
*/
107119
public function __construct(
108-
ProductIdLocatorInterface $productIdLocator,
109-
SearchCriteriaBuilder $searchCriteriaBuilder,
110-
FilterBuilder $filterBuilder,
111-
GroupRepositoryInterface $customerGroupRepository,
112-
WebsiteRepositoryInterface $websiteRepository,
113-
Result $validationResult,
114-
InvalidSkuProcessor $invalidSkuProcessor,
120+
ProductIdLocatorInterface $productIdLocator,
121+
SearchCriteriaBuilder $searchCriteriaBuilder,
122+
FilterBuilder $filterBuilder,
123+
GroupRepositoryInterface $customerGroupRepository,
124+
WebsiteRepositoryInterface $websiteRepository,
125+
Result $validationResult,
126+
InvalidSkuProcessor $invalidSkuProcessor,
115127
ProductRepositoryInterface $productRepository,
116-
array $allowedProductTypes = []
128+
array $allowedProductTypes = [],
129+
?ScopeConfigInterface $scopeConfig = null
117130
) {
118131
$this->productIdLocator = $productIdLocator;
119132
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
@@ -124,6 +137,7 @@ public function __construct(
124137
$this->invalidSkuProcessor = $invalidSkuProcessor;
125138
$this->productRepository = $productRepository;
126139
$this->allowedProductTypes = $allowedProductTypes;
140+
$this->scopeConfig = $scopeConfig ?: ObjectManager::getInstance()->get(ScopeConfigInterface::class);
127141
}
128142

129143
/**
@@ -355,10 +369,19 @@ private function checkQuantity(TierPriceInterface $price, $key, Result $validati
355369
* @param Result $validationResult
356370
* @return void
357371
*/
358-
private function checkWebsite(TierPriceInterface $price, $key, Result $validationResult)
372+
private function checkWebsite(TierPriceInterface $price, $key, Result $validationResult): void
359373
{
360374
try {
361375
$this->websiteRepository->getById($price->getWebsiteId());
376+
$isWebsiteScope = $this->scopeConfig
377+
->isSetFlag(
378+
Data::XML_PATH_PRICE_SCOPE,
379+
ScopeInterface::SCOPE_STORE,
380+
ScopeConfigInterface::SCOPE_TYPE_DEFAULT
381+
);
382+
if (!$isWebsiteScope && (int) $this->allWebsitesValue !== $price->getWebsiteId()) {
383+
throw NoSuchEntityException::singleField('website_id', $price->getWebsiteId());
384+
}
362385
} catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
363386
$validationResult->addFailedItem(
364387
$key,

app/code/Magento/Catalog/Test/Mftf/Test/AdminProductCategoryIndexerInUpdateOnScheduleModeTest.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
</annotations>
2323
<before>
2424
<actionGroup ref="AdminLoginActionGroup" stepKey="LoginAsAdmin"/>
25+
<actionGroup ref="CliIndexerReindexActionGroup" stepKey="performReindex">
26+
<argument name="indices" value=""/>
27+
</actionGroup>
28+
<actionGroup ref="CliCacheFlushActionGroup" stepKey="cleanCache">
29+
<argument name="tags" value=""/>
30+
</actionGroup>
2531
<!-- Create category A without products -->
2632
<createData entity="_defaultCategory" stepKey="createCategoryA"/>
2733

app/code/Magento/CatalogInventory/Test/Mftf/Test/StoreFrontAddOutOfStockProductToShoppingCartTest.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
</before>
4040
<!-- Delete the Data after execution-->
4141
<after>
42-
<deleteData createDataKey="createCategory" stepKey="deleteProduct"/>
43-
<deleteData createDataKey="simpleProductOne" stepKey="deleteCategory"/>
42+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
43+
<deleteData createDataKey="simpleProductOne" stepKey="deleteProduct"/>
4444
<magentoCLI command="config:set {{EnableInventoryCheckOnCartLoad.path}} {{EnableInventoryCheckOnCartLoad.value}}" stepKey="enableCartLoad"/>
4545
<actionGroup ref="AdminLogoutActionGroup" stepKey="adminLogout"/>
4646
</after>
@@ -62,8 +62,8 @@
6262
<!-- Mouse Hover Product On Category Page-->
6363
<actionGroup ref="StorefrontHoverProductOnCategoryPageActionGroup" stepKey="hoverProduct"/>
6464
<!-- Select Add to cart-->
65-
<waitForElementClickable selector="{{StorefrontCategoryMainSection.addToCartProductBySku($$simpleProductOne.sku$$)}}" stepKey="waitForAddToCartButton"/>
66-
<click selector="{{StorefrontCategoryMainSection.addToCartProductBySku($$simpleProductOne.sku$$)}}" stepKey="toCategory"/>
65+
<waitForElementClickable selector="{{StorefrontCategoryMainSection.AddToCartBtn}}" stepKey="waitForAddToCartButton"/>
66+
<click selector="{{StorefrontCategoryMainSection.AddToCartBtn}}" stepKey="toCategory"/>
6767
<waitForElementVisible selector="{{StorefrontProductPageSection.errorMsg}}" stepKey="wait"/>
6868
<!-- Assert the Error Message-->
6969
<see selector="{{StorefrontProductPageSection.errorMsg}}" userInput="Product that you are trying to add is not available." stepKey="seeErrorMessage"/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="StorefrontCheckForFlatRateShippingMethodAvailabilityActionGroup">
12+
<annotations>
13+
<description>Validates that the Shipping method is visible in the checkout page or not.</description>
14+
</annotations>
15+
<waitForElementVisible selector="{{CheckoutShippingMethodsSection.shippingMethodFlatRateLabel}}" stepKey="waitForFlatRateLabelVisible"/>
16+
<waitForElementVisible selector="{{CheckoutShippingMethodsSection.shippingMethodFlatRate}}" stepKey="waitForFlatRatePriceVisible"/>
17+
</actionGroup>
18+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="StorefrontVerifyDHLShippingMethodIsVisibilityActionGroup">
12+
<annotations>
13+
<description>Validates that the DHL Shipping method is visible in the checkout page.</description>
14+
</annotations>
15+
<waitForElementVisible selector="{{CheckoutShippingMethodsSection.shippingMethodDhlWorldWideExpressLabel}}" stepKey="waitForShippingDHLWorldWideExpressLabelVisible"/>
16+
<waitForElementVisible selector="{{CheckoutShippingMethodsSection.shippingMethodDhlWorldWideExpress}}" stepKey="waitForShippingDHLPriceVisible"/>
17+
<waitForElementVisible selector="{{CheckoutShippingMethodsSection.shippingMethodDhlExpressTwelveLabel}}" stepKey="waitForShippingDhlExpressTwelveLabelVisible"/>
18+
<waitForElementVisible selector="{{CheckoutShippingMethodsSection.shippingMethodDhlExpressTwelve}}" stepKey="waitForShippingDhlExpressTwelveVisible"/>
19+
<waitForElementVisible selector="{{CheckoutShippingMethodsSection.shippingMethodDhlMedicalExpressLabel}}" stepKey="waitForShippingDhlMedicalExpressLabelVisible"/>
20+
<waitForElementVisible selector="{{CheckoutShippingMethodsSection.shippingMethodDhlMedicalExpress}}" stepKey="waitForShippingDhlMedicalExpressVisible"/>
21+
</actionGroup>
22+
</actionGroups>

app/code/Magento/Checkout/Test/Mftf/Section/CheckoutShippingMethodsSection.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,15 @@
2626
<element name="showShippingVatNumber" type="text" selector="div.shipping-address-item"/>
2727
<element name="showBillingVatNumber" type="text" selector="div.billing-address-details"/>
2828
<element name="showShippingInfoVatNumber" type="text" selector="div.shipping-information-content"/>
29+
<element name="shippingMethodDhlLabel" type="text" selector="#label_carrier_null_dhl"/>
30+
<element name="shippingMethodFlatRateLabel" type="text" selector="#label_carrier_flatrate_flatrate"/>
31+
<element name="shippingMethodDhlWorldWideExpressLabel" type="text" selector="#label_method_P_dhl"/>
32+
<element name="shippingMethodDhlWorldWideExpress" type="radio" selector="#checkout-shipping-method-load input[value='dhl_P']"/>
33+
<element name="shippingMethodDhlExpressTwelveLabel" type="text" selector="#label_method_Y_dhl"/>
34+
<element name="shippingMethodDhlExpressTwelve" type="radio" selector="#checkout-shipping-method-load input[value='dhl_Y']"/>
35+
<element name="shippingMethodDhlMedicalExpressLabel" type="text" selector="#label_method_Q_dhl"/>
36+
<element name="shippingMethodDhlMedicalExpress" type="radio" selector="#checkout-shipping-method-load input[value='dhl_Q']"/>
37+
<element name="shippingMethodFreeShippingLabel" type="text" selector="#label_carrier_freeshipping_freeshipping"/>
38+
<element name="shippingDHLErrorMessage" type="text" selector="#checkout-shipping-method-load .table-checkout-shipping-method tr.row-error .error div"/>
2939
</section>
3040
</sections>

app/code/Magento/Checkout/Test/Mftf/Section/CheckoutSuccessMainSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@
2222
<element name="orderNumberWithoutLink" type="text" selector="//div[contains(@class, 'checkout-success')]//p/span"/>
2323
<element name="orderLinkByOrderNumber" type="text" selector="//div[contains(@class,'success')]//a[contains(.,'{{orderNumber}}')]" parameterized="true" timeout="30"/>
2424
<element name="purchaseOrderNumber" type="text" selector="div.checkout-success > p:nth-child(1) > a span"/>
25+
<element name="billingAgreement" type="text" selector="//div[contains(@class, 'checkout-success')]/p[contains(text(), 'Your billing agreement # is:')]"/>
2526
</section>
2627
</sections>

app/code/Magento/Checkout/Test/Mftf/Test/AdminCheckZeroSubtotalOrderWithCustomStatusTest.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@
4949
<magentoCLI command="config:set {{EnableFreeOrderStatusPending.path}} {{EnableFreeOrderStatusPending.value}}" stepKey="disablePaymentMethodsSettingConfig"/>
5050
<magentoCLI command="config:set {{EnableFreeOrderPaymentAutomaticInvoiceAction.path}} {{EnableFreeOrderPaymentAutomaticInvoiceAction.value}}" stepKey="enableFreeOrderPaymentAutomaticInvoiceAction"/>
5151
<actionGroup ref="CliDisableFreeShippingMethodActionGroup" stepKey="disableFreeShippingConfig"/>
52+
<!-- Unassign order status -->
53+
<actionGroup ref="AdminGoToOrderStatusPageActionGroup" stepKey="goToOrderStatus"/>
54+
<actionGroup ref="FilterOrderStatusByLabelAndCodeActionGroup" stepKey="filterStatusGrid">
55+
<argument name="statusLabel" value="{{defaultOrderStatus.label}}"/>
56+
<argument name="statusCode" value="{{defaultOrderStatus.status}}"/>
57+
</actionGroup>
58+
<click selector="{{AdminOrderStatusGridSection.unassign}}" stepKey="unassignOrderStatus"/>
59+
<waitForPageLoad stepKey="waitForGridLoad"/>
60+
5261
<deleteData createDataKey="simplecategory" stepKey="deleteCategory"/>
5362
<deleteData createDataKey="simpleproduct" stepKey="deleteProduct"/>
5463
<deleteData createDataKey="createCartPriceRule" stepKey="deleteSalesRule"/>

0 commit comments

Comments
 (0)