From 17aa13c9664fd55d02e535131b0d882102e61aab Mon Sep 17 00:00:00 2001 From: RomanKis Date: Fri, 3 Nov 2017 17:04:21 +0200 Subject: [PATCH 1/2] 11532: Duplicate Simple Product Throws Error: Undefined offset: 0 in SaveHandler.php on line 122 --- .../Catalog/Model/Category/Link/SaveHandler.php | 5 ++++- .../Unit/Model/Category/Link/SaveHandlerTest.php | 15 +++++++++++++++ 2 files changed, 19 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..3b66de87d0dea 100644 --- a/app/code/Magento/Catalog/Model/Category/Link/SaveHandler.php +++ b/app/code/Magento/Catalog/Model/Category/Link/SaveHandler.php @@ -119,7 +119,10 @@ 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 + ], ]; } From 3f79b80549bf42ebf96ead47d39824d949723daa Mon Sep 17 00:00:00 2001 From: RomanKis Date: Fri, 10 Nov 2017 17:32:16 +0200 Subject: [PATCH 2/2] 11532: Duplicate Simple Product Throws Error: Undefined offset: 0 in SaveHandler.php on line 122 --- app/code/Magento/Catalog/Model/Category/Link/SaveHandler.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Category/Link/SaveHandler.php b/app/code/Magento/Catalog/Model/Category/Link/SaveHandler.php index 3b66de87d0dea..f22c6903a230c 100644 --- a/app/code/Magento/Catalog/Model/Category/Link/SaveHandler.php +++ b/app/code/Magento/Catalog/Model/Category/Link/SaveHandler.php @@ -119,8 +119,7 @@ private function mergeCategoryLinks($newCategoryPositions, $oldCategoryPositions if ($key === false) { $result[] = $newCategoryPosition; - } elseif ( - isset($oldCategoryPositions[$key]) + } elseif (isset($oldCategoryPositions[$key]) && $oldCategoryPositions[$key]['position'] != $newCategoryPosition['position'] ) { $result[] = $newCategoryPositions[$key];