Skip to content

Commit 414a576

Browse files
committed
ACP2E-2978: Saving product by admin user with different role scope overwrites/deletes existing Related product information in the product
1 parent 43d48e3 commit 414a576

File tree

1 file changed

+7
-7
lines changed
  • app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization

1 file changed

+7
-7
lines changed

app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,12 @@ protected function setProductLinks(Product $product)
304304
$readonlyRelatedProducts = false;
305305
$readonlyUpSellProducts = false;
306306
foreach ($linkTypes as $linkType => $readonly) {
307+
if ($linkType === 'related' && $readonly) {
308+
$readonlyRelatedProducts = true;
309+
}
310+
if ($linkType === 'upsell' && $readonly) {
311+
$readonlyUpSellProducts = true;
312+
}
307313
if (isset($links[$linkType]) && !$readonly) {
308314
foreach ((array) $links[$linkType] as $linkData) {
309315
if (empty($linkData['id'])) {
@@ -319,15 +325,9 @@ protected function setProductLinks(Product $product)
319325
$productLinks[] = $link;
320326
}
321327
}
322-
if ($linkType === 'related' && $readonly) {
323-
$readonlyRelatedProducts = true;
324-
}
325-
if ($linkType === 'upsell' && $readonly) {
326-
$readonlyUpSellProducts = true;
327-
}
328328
}
329329
if ($readonlyRelatedProducts && $readonlyUpSellProducts && empty($productLinks)) {
330-
$productLinks = $currentProductLinks;
330+
return $product->setProductLinks($currentProductLinks);
331331
}
332332

333333
return $product->setProductLinks($productLinks);

0 commit comments

Comments
 (0)