From 95ed67ee4adbbd7f3f0107a52da4b9238cf44803 Mon Sep 17 00:00:00 2001 From: Magento EngCom Team Date: Tue, 23 Jan 2018 11:00:33 -0600 Subject: [PATCH] :arrow_double_up: Forwardport of magento/magento2#12001 to 2.3-develop branch Applied pull request patch https://github.com/magento/magento2/pull/12001.patch (created by @RomaKis) based on commit(s): 1. 17aa13c9664fd55d02e535131b0d882102e61aab 2. 3f79b80549bf42ebf96ead47d39824d949723daa Fixed GitHub Issues in 2.3-develop branch: - magento/magento2#11532: Duplicate Simple Product Throws Error: Undefined offset: 0 in SaveHandler.php on line 122 (reported by @lee586) --- .../Catalog/Model/Category/Link/SaveHandler.php | 4 +++- .../Unit/Model/Category/Link/SaveHandlerTest.php | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Model/Category/Link/SaveHandler.php b/app/code/Magento/Catalog/Model/Category/Link/SaveHandler.php index 29a1ef60a43de..f22c6903a230c 100644 --- a/app/code/Magento/Catalog/Model/Category/Link/SaveHandler.php +++ b/app/code/Magento/Catalog/Model/Category/Link/SaveHandler.php @@ -119,7 +119,9 @@ private function mergeCategoryLinks($newCategoryPositions, $oldCategoryPositions if ($key === false) { $result[] = $newCategoryPosition; - } elseif ($oldCategoryPositions[$key]['position'] != $newCategoryPosition['position']) { + } elseif (isset($oldCategoryPositions[$key]) + && $oldCategoryPositions[$key]['position'] != $newCategoryPosition['position'] + ) { $result[] = $newCategoryPositions[$key]; unset($oldCategoryPositions[$key]); } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Category/Link/SaveHandlerTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Category/Link/SaveHandlerTest.php index 78db12be56b42..0b85ef38387fa 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Category/Link/SaveHandlerTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Category/Link/SaveHandlerTest.php @@ -197,6 +197,21 @@ public function getCategoryDataProvider() ], [], //affected category_ids ], + [ + [3], //model category_ids + [ + ['category_id' => 3, 'position' => 20], + ['category_id' => 4, 'position' => 30], + ], // dto category links + [ + ['category_id' => 3, 'position' => 10], + ], + [ + ['category_id' => 3, 'position' => 20], + ['category_id' => 4, 'position' => 30], + ], + [3, 4], //affected category_ids + ], ]; }