Skip to content

Commit 983dbf4

Browse files
committed
Merge branch '2.4-develop' of github.com:magento-commerce/magento2ce into MCP-235
2 parents e915055 + f258736 commit 983dbf4

File tree

36 files changed

+833
-84
lines changed

36 files changed

+833
-84
lines changed

app/code/Magento/Bundle/Model/LinkManagement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ public function addChild(
367367
throw new CouldNotSaveException(__('Could not save child: "%1"', $e->getMessage()), $e);
368368
}
369369

370-
return $selectionModel->getId();
370+
return (int)$selectionModel->getId();
371371
}
372372

373373
/**
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\Bundle\Plugin\Api\ProductLinkManagement;
10+
11+
use Magento\Bundle\Api\ProductLinkManagementInterface;
12+
use Magento\Catalog\Api\ProductRepositoryInterface;
13+
use Magento\Catalog\Model\Indexer\Product\Full;
14+
15+
/**
16+
* Reindex bundle product after child has been added.
17+
*/
18+
class ReindexAfterAddChildBySkuPlugin
19+
{
20+
/**
21+
* @var Full
22+
*/
23+
private $indexer;
24+
25+
/**
26+
* @var ProductRepositoryInterface
27+
*/
28+
private $productRepository;
29+
30+
/**
31+
* @param Full $indexer
32+
* @param ProductRepositoryInterface $productRepository
33+
*/
34+
public function __construct(Full $indexer, ProductRepositoryInterface $productRepository)
35+
{
36+
$this->indexer = $indexer;
37+
$this->productRepository = $productRepository;
38+
}
39+
40+
/**
41+
* Reindex bundle product after child has been added.
42+
*
43+
* @param ProductLinkManagementInterface $subject
44+
* @param int $result
45+
* @param string $sku
46+
* @return int
47+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
48+
*/
49+
public function afterAddChildByProductSku(
50+
ProductLinkManagementInterface $subject,
51+
int $result,
52+
string $sku
53+
): int {
54+
$bundleProduct = $this->productRepository->get($sku, true);
55+
$this->indexer->executeRow($bundleProduct->getId());
56+
57+
return $result;
58+
}
59+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
declare(strict_types=1);
8+
9+
namespace Magento\Bundle\Plugin\Api\ProductLinkManagement;
10+
11+
use Magento\Bundle\Api\ProductLinkManagementInterface;
12+
use Magento\Catalog\Api\ProductRepositoryInterface;
13+
use Magento\Catalog\Model\Indexer\Product\Full;
14+
15+
/**
16+
* Reindex bundle product after child has been removed.
17+
*/
18+
class ReindexAfterRemoveChildPlugin
19+
{
20+
/**
21+
* @var Full
22+
*/
23+
private $indexer;
24+
25+
/**
26+
* @var ProductRepositoryInterface
27+
*/
28+
private $productRepository;
29+
30+
/**
31+
* @param Full $indexer
32+
* @param ProductRepositoryInterface $productRepository
33+
*/
34+
public function __construct(Full $indexer, ProductRepositoryInterface $productRepository)
35+
{
36+
$this->indexer = $indexer;
37+
$this->productRepository = $productRepository;
38+
}
39+
40+
/**
41+
* Reindex bundle product after child has been removed.
42+
*
43+
* @param ProductLinkManagementInterface $subject
44+
* @param bool $result
45+
* @param string $sku
46+
* @return bool
47+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
48+
*/
49+
public function afterRemoveChild(
50+
ProductLinkManagementInterface $subject,
51+
bool $result,
52+
string $sku
53+
): bool {
54+
$bundleProduct = $this->productRepository->get($sku, true);
55+
$this->indexer->executeRow($bundleProduct->getId());
56+
57+
return $result;
58+
}
59+
}

app/code/Magento/Bundle/etc/webapi_rest/di.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,8 @@
1313
</argument>
1414
</arguments>
1515
</type>
16+
<type name="Magento\Bundle\Api\ProductLinkManagementInterface">
17+
<plugin name="reindex_after_add_child_by_sku" type="Magento\Bundle\Plugin\Api\ProductLinkManagement\ReindexAfterAddChildBySkuPlugin"/>
18+
<plugin name="reindex_after_remove_child" type="Magento\Bundle\Plugin\Api\ProductLinkManagement\ReindexAfterRemoveChildPlugin"/>
19+
</type>
1620
</config>

app/code/Magento/Bundle/etc/webapi_soap/di.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,8 @@
1313
</argument>
1414
</arguments>
1515
</type>
16+
<type name="Magento\Bundle\Api\ProductLinkManagementInterface">
17+
<plugin name="reindex_after_add_child_by_sku" type="Magento\Bundle\Plugin\Api\ProductLinkManagement\ReindexAfterAddChildBySkuPlugin"/>
18+
<plugin name="reindex_after_remove_child" type="Magento\Bundle\Plugin\Api\ProductLinkManagement\ReindexAfterRemoveChildPlugin"/>
19+
</type>
1620
</config>

app/code/Magento/Catalog/Model/Design.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,21 @@ protected function _mergeSettings($categorySettings, $productSettings)
201201
$update = array_merge($categorySettings->getLayoutUpdates(), $productSettings->getLayoutUpdates());
202202
$categorySettings->setLayoutUpdates($update);
203203
}
204+
if ($categorySettings->getPageLayoutHandles()) {
205+
$handles = [];
206+
foreach ($categorySettings->getPageLayoutHandles() as $key => $value) {
207+
$handles[$key] = [
208+
'handle' => 'catalog_category_view',
209+
'value' => $value,
210+
];
211+
}
212+
$categorySettings->setPageLayoutHandles($handles);
213+
}
214+
if ($productSettings->getPageLayoutHandles()) {
215+
$handle = array_merge($categorySettings->getPageLayoutHandles(), $productSettings->getPageLayoutHandles());
216+
$categorySettings->setPageLayoutHandles($handle);
217+
}
218+
204219
return $categorySettings;
205220
}
206221
}

app/code/Magento/Catalog/Model/Product/Authorization.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ private function hasProductChanged(ProductModel $product, ?array $oldProduct = n
129129
//No new value
130130
continue;
131131
}
132-
if (!in_array($newValue, $oldValues, true)) {
132+
if ($newValue !== null && !in_array($newValue, $oldValues, true)) {
133133
return true;
134134
}
135135
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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="StorefrontRemoveFirstProductFromCompareActionGroup">
12+
<annotations>
13+
<description>Open Compare Products list and remove a product</description>
14+
</annotations>
15+
16+
<amOnPage url="{{StorefrontProductComparePage.url}}" stepKey="navigateToComparePage"/>
17+
<waitForElementVisible selector="{{StorefrontProductCompareMainSection.removeFirstItem}}" stepKey="waitForButton"/>
18+
<click selector="{{StorefrontProductCompareMainSection.removeFirstItem}}" stepKey="clickOnButton"/>
19+
<waitForElementVisible selector="{{ModalConfirmationSection.OkButton}}" stepKey="waitForModal"/>
20+
<scrollTo selector="{{ModalConfirmationSection.OkButton}}" stepKey="scrollToModal"/>
21+
<click selector="{{ModalConfirmationSection.OkButton}}" stepKey="ClickOkButton"/>
22+
<waitForElementVisible selector="{{StorefrontMessagesSection.success}}" stepKey="waitForSuccessMessage"/>
23+
</actionGroup>
24+
</actionGroups>

app/code/Magento/Catalog/Test/Mftf/Section/StorefrontProductCompareMainSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
<element name="ProductPriceByName" type="text" selector="//*[@id='product-comparison']//td[.//strong[@class='product-item-name']/a[contains(text(), '{{var1}}')]]//span[@class='price']" parameterized="true"/>
1515
<element name="ProductImageByName" type="text" selector="//*[@id='product-comparison']//td[.//strong[@class='product-item-name']/a[contains(text(), '{{var1}}')]]//img[@class='product-image-photo']" parameterized="true"/>
1616
<element name="ProductAttributeByCodeAndProductName" type="text" selector="//*[@id='product-comparison']//tr[.//th[./span[contains(text(), '{{var1}}')]]]//td[count(//*[@id='product-comparison']//tr//td[.//strong[@class='product-item-name']/a[contains(text(), '{{var2}}')]]/preceding-sibling::td)+1]/div" parameterized="true"/>
17+
<element name="removeFirstItem" type="button" selector="table.table-comparison a.delete"/>
1718
</section>
1819
</sections>

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@
7878
<actionGroup ref="StorefrontGoToCategoryPageActionGroup" stepKey="openCategoryPage">
7979
<argument name="categoryName" value="$$category.name$$"/>
8080
</actionGroup>
81-
82-
<actionGroup ref="StorefrontOpenAndCheckComparisionActionGroup" stepKey="navigateToComparePage"/>
81+
<comment userInput="Comment is kept to preserve the step key for backward compatibility" stepKey="navigateToComparePage"/>
8382
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForStorefrontProductComparePageLoad"/>
8483

8584
<actionGroup ref="SeeProductInComparisonListActionGroup" stepKey="seeProductInCompareList">
@@ -92,11 +91,13 @@
9291
<argument name="categoryName" value="$$category.name$$"/>
9392
</actionGroup>
9493

95-
<actionGroup ref="StorefrontClearCompareActionGroup" stepKey="clickClearAll"/>
94+
<actionGroup ref="StorefrontRemoveFirstProductFromCompareActionGroup" stepKey="clickClearAll"/>
9695
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForConfirmPageLoad"/>
9796
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="confirmProdDelate"/>
9897
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForConfirmLoad"/>
99-
<comment userInput="Add product to compare list fom Category page | Comment is kept to preserve the step key for backward compatibility" stepKey="addToCmpFromCategPage"/>
98+
<actionGroup ref="StorefrontGoToCategoryPageActionGroup" stepKey="addToCmpFromCategPage">
99+
<argument name="categoryName" value="$$category.name$$"/>
100+
</actionGroup>
100101

101102
<actionGroup ref="StorefrontHoverProductOnCategoryPageActionGroup" stepKey="hoverOverProduct"/>
102103

@@ -108,11 +109,11 @@
108109
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="grabTextFromSuccessMessage2"/>
109110
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="assertSuccessMessage2"/>
110111

111-
<comment userInput="Check that product displays on add to compare widget | Comment is kept to preserve the step key for backward compatibility" stepKey="checkProdNameOnWidget"/>
112-
<seeElement selector="{{StorefrontComparisonSidebarSection.ProductTitleByName($$product.name$$)}}" stepKey="seeProdNameOnCmpWidget"/>
112+
<comment userInput="Comment is kept to preserve the step key for backward compatibility" stepKey="checkProdNameOnWidget"/>
113+
<comment userInput="Comment is kept to preserve the step key for backward compatibility" stepKey="seeProdNameOnCmpWidget"/>
113114

114115
<comment userInput="See product in the compare page" stepKey="seeProductInComparePage"/>
115-
<actionGroup ref="StorefrontOpenAndCheckComparisionActionGroup" stepKey="navigateToComparePage2"/>
116+
<comment userInput="Comment is kept to preserve the step key for backward compatibility" stepKey="navigateToComparePage2"/>
116117
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="waitForStorefrontProductComparePageLoad2"/>
117118

118119
<actionGroup ref="SeeProductInComparisonListActionGroup" stepKey="seeProductInCompareList2">

0 commit comments

Comments
 (0)