Skip to content

Commit 0ef1ece

Browse files
committed
Merge branch '2.4-develop' of https://github.com/magento/magento2ce into PRodubovyk20210225
2 parents cd618a4 + bc0ff78 commit 0ef1ece

File tree

33 files changed

+77364
-27388
lines changed

33 files changed

+77364
-27388
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
}

app/code/Magento/Cms/Controller/Adminhtml/Page/InlineEdit.php

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ public function execute()
8383
/** @var \Magento\Cms\Model\Page $page */
8484
$page = $this->pageRepository->getById($pageId);
8585
try {
86-
$pageData = $this->filterPost($postItems[$pageId]);
87-
$this->validatePost($pageData, $page, $error, $messages);
8886
$extendedPageData = $page->getData();
87+
$pageData = $this->filterPostWithDateConverting($postItems[$pageId], $extendedPageData);
88+
$this->validatePost($pageData, $page, $error, $messages);
8989
$this->setCmsPageData($page, $extendedPageData, $pageData);
9090
$this->pageRepository->save($page);
9191
} catch (\Magento\Framework\Exception\LocalizedException $e) {
@@ -127,6 +127,34 @@ protected function filterPost($postData = [])
127127
return $pageData;
128128
}
129129

130+
/**
131+
* Filtering posted data with converting custom theme dates to proper format
132+
*
133+
* @param array $postData
134+
* @param array $pageData
135+
* @return array
136+
*/
137+
private function filterPostWithDateConverting($postData = [], $pageData = [])
138+
{
139+
$newPageData = $this->filterPost($postData);
140+
if (
141+
!empty($newPageData['custom_theme_from'])
142+
&& date("Y-m-d", strtotime($postData['custom_theme_from']))
143+
=== date("Y-m-d", strtotime($pageData['custom_theme_from']))
144+
) {
145+
$newPageData['custom_theme_from'] = date("Y-m-d", strtotime($postData['custom_theme_from']));
146+
}
147+
if (
148+
!empty($newPageData['custom_theme_to'])
149+
&& date("Y-m-d", strtotime($postData['custom_theme_to']))
150+
=== date("Y-m-d", strtotime($pageData['custom_theme_to']))
151+
) {
152+
$newPageData['custom_theme_to'] = date("Y-m-d", strtotime($postData['custom_theme_to']));
153+
}
154+
155+
return $newPageData;
156+
}
157+
130158
/**
131159
* Validate post data
132160
*

app/code/Magento/Cms/Test/Mftf/Page/CmsPagesPage.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd">
1111
<page name="CmsPagesPage" url="/cms/page" area="admin" module="Magento_Cms">
1212
<section name="CmsPagesPageActionsSection"/>
13+
<section name="AdminCmsPageGridInlineEditSection"/>
1314
</page>
1415
</pages>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
10+
<section name="AdminCmsPageGridInlineEditSection">
11+
<element name="customDesignFrom" type="input" selector="tr.data-grid-editable-row:not([style*='display: none']) [name='custom_theme_from']"/>
12+
<element name="customDesignTo" type="input" selector="tr.data-grid-editable-row:not([style*='display: none']) [name='custom_theme_to']"/>
13+
<element name="customLayout" type="input" selector="tr.data-grid-editable-row:not([style*='display: none']) [name='page_layout']"/>
14+
<element name="savePageButton" type="button" selector="tr.data-grid-editable-row-actions button.action-primary" timeout="30"/>
15+
</section>
16+
</sections>

0 commit comments

Comments
 (0)