Skip to content

Commit 7ad60dd

Browse files
committed
MC-40777: Cannot save product in store view scope without Magento_Catalog::edit_product_design
1 parent 3b397a9 commit 7ad60dd

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
use Magento\Catalog\Model\Product as ProductModel;
1313
use Magento\Catalog\Model\ProductFactory;
1414
use Magento\Eav\Api\Data\AttributeInterface;
15+
use Magento\Framework\App\ObjectManager;
16+
use Magento\Framework\App\RequestInterface;
1517
use Magento\Framework\AuthorizationInterface;
1618
use Magento\Framework\Exception\AuthorizationException;
1719
use Magento\Framework\Exception\NoSuchEntityException;
@@ -32,14 +34,24 @@ class Authorization
3234
*/
3335
private $productFactory;
3436

37+
/**
38+
* @var RequestInterface
39+
*/
40+
protected $request;
41+
3542
/**
3643
* @param AuthorizationInterface $authorization
3744
* @param ProductFactory $factory
45+
* @param RequestInterface|null $request
3846
*/
39-
public function __construct(AuthorizationInterface $authorization, ProductFactory $factory)
40-
{
47+
public function __construct(
48+
AuthorizationInterface $authorization,
49+
ProductFactory $factory,
50+
?RequestInterface $request = null
51+
) {
4152
$this->authorization = $authorization;
4253
$this->productFactory = $factory;
54+
$this->request = $request ?: ObjectManager::getInstance()->get(RequestInterface::class);;
4355
}
4456

4557
/**
@@ -121,6 +133,10 @@ private function hasProductChanged(ProductModel $product, ?array $oldProduct = n
121133
if (!array_key_exists($designAttribute, $attributes)) {
122134
continue;
123135
}
136+
$useDefaults = (array) $this->request->getPost('use_default', []);
137+
if (isset($useDefaults[$designAttribute]) && $useDefaults[$designAttribute]) {
138+
continue;
139+
}
124140
$attribute = $attributes[$designAttribute];
125141
$oldValues = $this->fetchOldValues($attribute, $oldProduct);
126142
try {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ public function postRequestData(): array
9292
'page_layout' => '',
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' => [

0 commit comments

Comments
 (0)