Skip to content

Commit be9cbd3

Browse files
committed
MC-40811: Schedule Design Update when edit product in backend seem not set properly
1 parent 5aebec8 commit be9cbd3

File tree

2 files changed

+12
-22
lines changed

2 files changed

+12
-22
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ protected function _extractSettings($object)
151151
return $settings;
152152
}
153153
$settings->setPageLayout($object->getPageLayout());
154+
$settings->setLayoutUpdates((array)$object->getCustomLayoutUpdate());
154155

155156
$date = $object->getCustomDesignDate();
156157
if (array_key_exists(
@@ -165,13 +166,12 @@ protected function _extractSettings($object)
165166
$date['to']
166167
)
167168
) {
168-
$settings->setCustomDesign(
169-
$object->getCustomDesign()
170-
)->setPageLayout(
171-
$object->getCustomLayout()
172-
)->setLayoutUpdates(
173-
(array)$object->getCustomLayoutUpdate()
174-
);
169+
if ($object->getCustomDesign()) {
170+
$settings->setCustomDesign($object->getCustomDesign());
171+
}
172+
if ($object->getCustomLayout()) {
173+
$settings->setPageLayout($object->getCustomLayout());
174+
}
175175
if ($object instanceof Category) {
176176
$this->categoryLayoutUpdates->extractCustomSettings($object, $settings);
177177
} elseif ($object instanceof Product) {

dev/tests/integration/testsuite/Magento/Catalog/_files/simple_product_with_custom_design.php

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
67

7-
use Magento\Catalog\Model\Product;
8+
use Magento\Catalog\Api\ProductRepositoryInterface;
89
use Magento\Catalog\Model\Product\Attribute\Source\Status;
910
use Magento\Catalog\Model\Product\Visibility;
1011
use Magento\Catalog\Model\ProductFactory;
1112
use Magento\TestFramework\Helper\Bootstrap;
1213

1314
$product = Bootstrap::getObjectManager()->create(ProductFactory::class)->create();
15+
$productRepository = Bootstrap::getObjectManager()->get(ProductRepositoryInterface::class);
1416
$product->setTypeId('simple')
1517
->setPageLayout('3columns')
1618
->setAttributeSetId(4)
@@ -20,18 +22,6 @@
2022
->setPrice(10)
2123
->setVisibility(Visibility::VISIBILITY_BOTH)
2224
->setStatus(Status::STATUS_ENABLED)
23-
->setStockData(['use_config_manage_stock' => 1, 'qty' => 100, 'is_in_stock' => 1])
24-
->save();
25+
->setStockData(['use_config_manage_stock' => 1, 'qty' => 100, 'is_in_stock' => 1]);
2526

26-
$customDesignProduct = Bootstrap::getObjectManager()
27-
->create(Product::class, ['data' => $product->getData()]);
28-
29-
$customDesignProduct->setUrlKey('custom-design-simple-product')
30-
->setId(2)
31-
->setRowId(2)
32-
->setName('Custom Design Simple Product')
33-
->setSku('custom-design-simple-product')
34-
->setCustomDesign('Magento/blank')
35-
->setStockData(['use_config_manage_stock' => 1, 'qty' => 24, 'is_in_stock' => 1])
36-
->setQty(24)
37-
->save();
27+
$productRepository->save($product);

0 commit comments

Comments
 (0)