Skip to content

Commit 1d3340d

Browse files
committed
Merge remote-tracking branch 'magento-commerce/2.4-develop' into ACP2E-3950
2 parents b34ba1e + a20a6ff commit 1d3340d

File tree

26 files changed

+384
-119
lines changed

26 files changed

+384
-119
lines changed

app/code/Magento/Bundle/Test/Mftf/ActionGroup/AssertStorefrontBundleValidationMessageActionGroup.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
</arguments>
1818

1919
<waitForPageLoad stepKey="waitForPageLoad"/>
20-
<see selector="{{StorefrontBundledSection.validationMessageBox}}" userInput="{{message}}" stepKey="seeErrorHoldMessage"/>
20+
<see selector="{{StorefrontBundledSection.selectOptionError}}" userInput="{{message}}" stepKey="seeErrorHoldMessage"/>
2121
</actionGroup>
2222
</actionGroups>

app/code/Magento/Bundle/Test/Mftf/ActionGroup/AssertStorefrontBundleValidationMessagesCountActionGroup.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</annotations>
1515

1616
<waitForPageLoad stepKey="waitForPageLoad"/>
17-
<seeElement selector="{{StorefrontBundledSection.validationMessageBox}}" stepKey="seeErrorBox"/>
18-
<seeNumberOfElements selector="{{StorefrontBundledSection.validationMessageBox}}" userInput="1" stepKey="seeOneErrorBox"/>
17+
<seeElement selector="{{StorefrontBundledSection.selectOptionError}}" stepKey="seeErrorBox"/>
18+
<seeNumberOfElements selector="{{StorefrontBundledSection.selectOptionError}}" userInput="1" stepKey="seeOneErrorBox"/>
1919
</actionGroup>
2020
</actionGroups>

app/code/Magento/Bundle/Test/Mftf/Section/StorefrontBundledSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,6 @@
5151
<element name="dropDownQuantityValidation" type="input" selector="//span[contains(text(), '{{productName}}')]/../..//input/following-sibling::div[@class='mage-error']" parameterized="true"/>
5252
<element name="radioButtonQuantityValidation" type="input" selector="//label//span[contains(text(), '{{productName}}')]/../..//div[@class='control']//div[@class='field qty qty-holder']//input/following-sibling::div[@class='mage-error']" parameterized="true"/>
5353
<element name="dropDrownOptionQuantity" type="input" selector="//span[contains(text(), '{{productName}}')]/../..//input/following-sibling::div//div//div//input" parameterized="true"/>
54+
<element name="selectOptionError" type="text" selector="//div[contains(@class, 'field')]//div[contains(@class, 'mage-error')]"/>
5455
</section>
5556
</sections>

app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleCheckBoxOptionValidationTest.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@
1717
<testCaseId value="MC-35133"/>
1818
<severity value="MINOR"/>
1919
<group value="Bundle"/>
20-
<group value="pr_exclude"/>
2120
<group value="cloud"/>
22-
<skip>
23-
<issueId value="AC-10826"/>
24-
</skip>
2521
</annotations>
2622
<before>
2723
<createData entity="ApiProductWithDescription" stepKey="simpleProduct1" before="bundleProduct"/>

app/code/Magento/Catalog/Model/Product/Gallery/CreateHandler.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,18 @@ public function execute($product, $arguments = [])
219219
$clearImages[] = $image['file'];
220220
} elseif (empty($image['value_id']) || !empty($image['recreate'])) {
221221
$newFile = $this->moveImageFromTmp($image['file'] ?? '');
222-
$image['new_file'] = $newFile;
223-
$newImages[$image['file']] = $image;
224-
$image['file'] = $newFile;
222+
if (!empty($image['recreate']) && $newFile !== $image['file']) {
223+
//delete old image
224+
$this->mediaDirectory->renameFile(
225+
$this->mediaConfig->getMediaPath($newFile),
226+
$this->mediaConfig->getMediaPath($image['file'])
227+
);
228+
$existImages[$image['file']] = $image;
229+
} else {
230+
$image['new_file'] = $newFile;
231+
$newImages[$image['file']] = $image;
232+
$image['file'] = $newFile;
233+
}
225234
} else {
226235
$existImages[$image['file']] = $image;
227236
}

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

Lines changed: 0 additions & 24 deletions
This file was deleted.

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020
<group value="catalog"/>
2121
<group value="CatalogInventory"/>
2222
<group value="product_attributes"/>
23-
<skip>
24-
<issueId value="ACQE-4352"/>
25-
</skip>
2623
</annotations>
2724
<before>
2825
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
@@ -48,8 +45,11 @@
4845
<argument name="keyword" value="api-simple-product"/>
4946
</actionGroup>
5047
<actionGroup ref="SortProductsByIdDescendingActionGroup" stepKey="sortProductsByIdDescending"/>
48+
<waitForElementClickable selector="{{AdminProductGridSection.productGridCheckboxOnRow('1')}}" stepKey="waitForSelectCheckbox1"/>
5149
<checkOption selector="{{AdminProductGridSection.productGridCheckboxOnRow('1')}}" stepKey="clickCheckbox1"/>
5250
<checkOption selector="{{AdminProductGridSection.productGridCheckboxOnRow('2')}}" stepKey="clickCheckbox2"/>
51+
<seeCheckboxIsChecked selector="{{AdminProductGridSection.productGridCheckboxOnRow('1')}}" stepKey="seeProduct1IsChecked"/>
52+
<seeCheckboxIsChecked selector="{{AdminProductGridSection.productGridCheckboxOnRow('2')}}" stepKey="seeProduct2IsChecked"/>
5353
<!-- Mass update qty increments -->
5454
<actionGroup ref="AdminClickMassUpdateProductAttributesActionGroup" stepKey="clickMassUpdateProductAttributes"/>
5555
<actionGroup ref="AdminMassUpdateProductQtyIncrementsActionGroup" stepKey="updateQtyIncrements">

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,13 @@
105105
</actionGroup>
106106

107107
<!-- Check the total number of expanded categories in the category tree widget ensuring all of them are loaded. -->
108-
<actionGroup ref="AdminAssertCategoryCountInCategoryTreeWidgetActionGroup" stepKey="checkCategoryCount">
109-
<argument name="ExpectedCount" value="9"/>
110-
</actionGroup>
108+
<waitForElementVisible selector="{{CmsNewWidgetUpdateLayoutSection.CategoryName('$$createBaseCategory.name$$')}}" stepKey="waitForBaseCategoryVisible"/>
109+
<waitForElementVisible selector="{{CmsNewWidgetUpdateLayoutSection.CategoryName('$$createLevelTwoCategory.name$$')}}" stepKey="waitForLevelTwoCategoryVisible"/>
110+
<waitForElementVisible selector="{{CmsNewWidgetUpdateLayoutSection.CategoryName('$$createLevelThreeCategory.name$$')}}" stepKey="waitForLevelThreeCategoryVisible"/>
111+
<waitForElementVisible selector="{{CmsNewWidgetUpdateLayoutSection.CategoryName('$$createLevelFourCategory.name$$')}}" stepKey="waitForLevelFourCategoryVisible"/>
112+
<waitForElementVisible selector="{{CmsNewWidgetUpdateLayoutSection.CategoryName('$$createLevelFiveCategory.name$$')}}" stepKey="waitForLevelFiveCategoryVisible"/>
113+
<waitForElementVisible selector="{{CmsNewWidgetUpdateLayoutSection.CategoryName('$$createLevelSixCategory.name$$')}}" stepKey="waitForLevelSixCategoryVisible"/>
114+
<waitForElementVisible selector="{{CmsNewWidgetUpdateLayoutSection.CategoryName('$$createLevelFiveSubCategory.name$$')}}" stepKey="waitForLevelFiveSubCategoryVisible"/>
115+
<waitForElementVisible selector="{{CmsNewWidgetUpdateLayoutSection.CategoryName('$$createLevelFiveOneSubCategory.name$$')}}" stepKey="waitForLevelFiveOneSubCategoryVisible"/>
111116
</test>
112117
</tests>

app/code/Magento/CatalogRule/Model/Indexer/ReindexRuleProduct.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,18 @@ public function execute(Rule $rule, $batchCount, $useAdditionalTable = false)
129129
continue;
130130
}
131131

132+
if (isset($validationByWebsite['has_antecedent_rule'])) {
133+
$antecedentRuleProductList = array_keys(
134+
$connection->fetchAssoc(
135+
$connection->select()->from($indexTable)
136+
->where('product_id = ?', $productId)
137+
->where('rule_id NOT IN (?)', $rule->getId())
138+
->where('sort_order = ?', $sortOrder)
139+
)
140+
);
141+
$connection->delete($indexTable, ['rule_product_id IN (?)' => $antecedentRuleProductList]);
142+
}
143+
132144
foreach ($customerGroupIds as $customerGroupId) {
133145
if (!array_key_exists($customerGroupId, $excludedWebsites)
134146
|| !in_array((int)$websiteId, array_values($excludedWebsites[$customerGroupId]), true)

app/code/Magento/CatalogRuleConfigurable/Plugin/CatalogRule/Model/Rule/ConfigurableProductHandler.php

Lines changed: 60 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,40 @@
33
* Copyright 2015 Adobe
44
* All Rights Reserved.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\CatalogRuleConfigurable\Plugin\CatalogRule\Model\Rule;
79

8-
use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
910
use Magento\CatalogRuleConfigurable\Plugin\CatalogRule\Model\ConfigurableProductsProvider;
11+
use Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable as ConfigurableProductsResourceModel;
1012

1113
/**
1214
* Add configurable sub products to catalog rule indexer on full reindex
1315
*/
1416
class ConfigurableProductHandler
1517
{
1618
/**
17-
* @var \Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable
19+
* @var ConfigurableProductsResourceModel
1820
*/
19-
private $configurable;
21+
private ConfigurableProductsResourceModel $configurable;
2022

2123
/**
22-
* @var \Magento\CatalogRuleConfigurable\Plugin\CatalogRule\Model\ConfigurableProductsProvider
24+
* @var ConfigurableProductsProvider
2325
*/
24-
private $configurableProductsProvider;
26+
private ConfigurableProductsProvider $configurableProductsProvider;
2527

2628
/**
2729
* @var array
2830
*/
29-
private $childrenProducts = [];
31+
private array $childrenProducts = [];
3032

3133
/**
32-
* @param \Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable $configurable
34+
* @param ConfigurableProductsResourceModel $configurable
3335
* @param ConfigurableProductsProvider $configurableProductsProvider
3436
*/
3537
public function __construct(
36-
\Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable $configurable,
37-
ConfigurableProductsProvider $configurableProductsProvider
38+
ConfigurableProductsResourceModel $configurable,
39+
ConfigurableProductsProvider $configurableProductsProvider
3840
) {
3941
$this->configurable = $configurable;
4042
$this->configurableProductsProvider = $configurableProductsProvider;
@@ -48,40 +50,71 @@ public function __construct(
4850
* @return array
4951
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
5052
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
53+
* @SuppressWarnings(PHPMD.NPathComplexity)
54+
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
5155
*/
5256
public function aroundGetMatchingProductIds(
5357
\Magento\CatalogRule\Model\Rule $rule,
5458
\Closure $proceed
55-
) {
59+
): array {
5660
$productsFilter = $rule->getProductsFilter() ? (array) $rule->getProductsFilter() : [];
5761
if ($productsFilter) {
58-
$parentProductIds = $this->configurable->getParentIdsByChild($productsFilter);
59-
$rule->setProductsFilter(array_unique(array_merge($productsFilter, $parentProductIds)));
62+
$rule->setProductsFilter(
63+
array_unique(
64+
array_merge(
65+
$productsFilter,
66+
$this->configurable->getParentIdsByChild($productsFilter)
67+
)
68+
)
69+
);
6070
}
6171

6272
$productIds = $proceed();
73+
foreach ($productIds as $productId => $productData) {
74+
if ($this->hasAntecedentRule((int) $productId)) {
75+
$productIds[$productId]['has_antecedent_rule'] = true;
76+
}
77+
}
6378

64-
$configurableProductIds = $this->configurableProductsProvider->getIds(array_keys($productIds));
65-
foreach ($configurableProductIds as $productId) {
66-
if (!isset($this->childrenProducts[$productId])) {
67-
$this->childrenProducts[$productId] = $this->configurable->getChildrenIds($productId)[0];
79+
foreach ($this->configurableProductsProvider->getIds(array_keys($productIds)) as $configurableProductId) {
80+
if (!isset($this->childrenProducts[$configurableProductId])) {
81+
$this->childrenProducts[$configurableProductId] =
82+
$this->configurable->getChildrenIds($configurableProductId)[0];
6883
}
69-
$subProductIds = $this->childrenProducts[$productId];
70-
$parentValidationResult = isset($productIds[$productId])
71-
? array_filter($productIds[$productId])
84+
85+
$parentValidationResult = isset($productIds[$configurableProductId])
86+
? array_filter($productIds[$configurableProductId])
7287
: [];
73-
$processAllChildren = !$productsFilter || in_array($productId, $productsFilter);
74-
foreach ($subProductIds as $subProductId) {
75-
if ($processAllChildren || in_array($subProductId, $productsFilter)) {
76-
$childValidationResult = isset($productIds[$subProductId])
77-
? array_filter($productIds[$subProductId])
88+
$processAllChildren = !$productsFilter || in_array($configurableProductId, $productsFilter);
89+
foreach ($this->childrenProducts[$configurableProductId] as $childrenProductId) {
90+
if ($processAllChildren || in_array($childrenProductId, $productsFilter)) {
91+
$childValidationResult = isset($productIds[$childrenProductId])
92+
? array_filter($productIds[$childrenProductId])
7893
: [];
79-
$productIds[$subProductId] = $parentValidationResult + $childValidationResult;
94+
$productIds[$childrenProductId] = $parentValidationResult + $childValidationResult;
8095
}
81-
8296
}
83-
unset($productIds[$productId]);
97+
unset($productIds[$configurableProductId]);
8498
}
99+
85100
return $productIds;
86101
}
102+
103+
/**
104+
* Check if simple product has previously applied rule.
105+
*
106+
* @param int $productId
107+
* @return bool
108+
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
109+
*/
110+
private function hasAntecedentRule(int $productId): bool
111+
{
112+
foreach ($this->childrenProducts as $parent => $children) {
113+
if (in_array($productId, $children)) {
114+
return true;
115+
}
116+
}
117+
118+
return false;
119+
}
87120
}

0 commit comments

Comments
 (0)