Skip to content

Commit 5854e9b

Browse files
committed
Merge remote-tracking branch 'origin/imported-magento-magento2-31998' into 2.4-develop-pr127
2 parents 5c360b8 + c28a878 commit 5854e9b

File tree

4 files changed

+82
-9
lines changed

4 files changed

+82
-9
lines changed

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
}

dev/tests/integration/testsuite/Magento/Catalog/Model/Product/AuthorizationTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ protected function setUp(): void
5858
/**
5959
* Verify AuthorizedSavingOf
6060
*
61-
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
61+
* @magentoDataFixture Magento/Catalog/_files/product_simple_with_design_attributes.php
6262
* @param array $data
6363
*
6464
* @dataProvider postRequestData
@@ -68,7 +68,7 @@ public function testAuthorizedSavingOf(array $data): void
6868
$this->request->setPost(new Parameters($data));
6969

7070
/** @var Product $product */
71-
$product = $this->productRepository->get('simple');
71+
$product = $this->productRepository->get('simple_design_attribute');
7272

7373
$product = $this->initializationHelper->initialize($product);
7474
$this->assertEquals('simple_new', $product->getName());
@@ -88,12 +88,12 @@ public function postRequestData(): array
8888
[
8989
'product' => [
9090
'name' => 'simple_new',
91-
'custom_design' => '',
92-
'page_layout' => '',
91+
'custom_design' => '3',
92+
'page_layout' => '1column',
9393
'options_container' => 'container2',
9494
'custom_layout_update' => '',
95-
'custom_design_from' => '',
96-
'custom_design_to' => '',
95+
'custom_design_from' => '2021-02-19 00:00:00',
96+
'custom_design_to' => '2021-02-09 00:00:00',
9797
'custom_layout_update_file' => '',
9898
],
9999
'use_default' => [
@@ -114,8 +114,8 @@ public function postRequestData(): array
114114
'page_layout' => '',
115115
'options_container' => 'container2',
116116
'custom_design' => '',
117-
'custom_design_from' => '',
118-
'custom_design_to' => '',
117+
'custom_design_from' => '2020-01-02',
118+
'custom_design_to' => '2020-01-03',
119119
'custom_layout' => '',
120120
'custom_layout_update_file' => '__no_update__',
121121
],
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
use Magento\Catalog\Api\ProductRepositoryInterface;
9+
use Magento\Catalog\Model\Product\Attribute\Source\Status;
10+
use Magento\Catalog\Model\Product\Type;
11+
use Magento\Catalog\Model\Product\Visibility;
12+
use Magento\Catalog\Model\ProductFactory;
13+
use Magento\Store\Api\WebsiteRepositoryInterface;
14+
use Magento\TestFramework\Helper\Bootstrap;
15+
16+
$objectManager = Bootstrap::getObjectManager();
17+
/** @var ProductFactory $productFactory */
18+
$productFactory = $objectManager->get(ProductFactory::class);
19+
/** @var WebsiteRepositoryInterface $websiteRepository */
20+
$websiteRepository = $objectManager->get(WebsiteRepositoryInterface::class);
21+
$defaultWebsiteId = $websiteRepository->get('base')->getId();
22+
$product = $productFactory->create();
23+
$product->isObjectNew(true);
24+
$product->setTypeId(Type::TYPE_SIMPLE)
25+
->setAttributeSetId($product->getDefaultAttributeSetId())
26+
->setWebsiteIds([$defaultWebsiteId])
27+
->setName('Simple with design attribute')
28+
->setSku('simple_design_attribute')
29+
->setPrice(10)
30+
->setWeight(1)
31+
->setShortDescription('Short description')
32+
->setTaxClassId(0)
33+
->setDescription('Description with <b>html tag</b>')
34+
->setMetaTitle('meta title')
35+
->setMetaKeyword('meta keyword')
36+
->setMetaDescription('meta description')
37+
->setVisibility(Visibility::VISIBILITY_BOTH)
38+
->setStatus(Status::STATUS_ENABLED)
39+
->setStockData(['use_config_manage_stock' => 0])
40+
->setCanSaveCustomOptions(true)
41+
->setCustomDesignFrom('2020-01-02')
42+
->setCustomDesignTo('2020-01-03')
43+
->setHasOptions(true);
44+
/** @var ProductRepositoryInterface $productRepositoryFactory */
45+
$productRepository = $objectManager->get(ProductRepositoryInterface::class);
46+
$productRepository->save($product);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
use Magento\Framework\Exception\NoSuchEntityException;
9+
10+
\Magento\TestFramework\Helper\Bootstrap::getInstance()->getInstance()->reinitialize();
11+
12+
/** @var \Magento\Framework\Registry $registry */
13+
$registry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(\Magento\Framework\Registry::class);
14+
15+
$registry->unregister('isSecureArea');
16+
$registry->register('isSecureArea', true);
17+
18+
/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */
19+
$productRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
20+
->get(\Magento\Catalog\Api\ProductRepositoryInterface::class);
21+
try {
22+
$product = $productRepository->get('simple_design_attribute', false, null, true);
23+
$productRepository->delete($product);
24+
} catch (NoSuchEntityException $e) {
25+
}
26+
$registry->unregister('isSecureArea');
27+
$registry->register('isSecureArea', false);

0 commit comments

Comments
 (0)