Skip to content

Commit 8ba9837

Browse files
author
Oleksii Korshenko
authored
MAGETWO-83627: 11532: Duplicate Simple Product Throws Error: Undefined offset: 0 in SaveHandler.php on line 122 #12001
2 parents e8cd40c + 3c9d94d commit 8ba9837

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

app/code/Magento/Catalog/Model/Category/Link/SaveHandler.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ private function mergeCategoryLinks($newCategoryPositions, $oldCategoryPositions
119119

120120
if ($key === false) {
121121
$result[] = $newCategoryPosition;
122-
} elseif ($oldCategoryPositions[$key]['position'] != $newCategoryPosition['position']) {
122+
} elseif (isset($oldCategoryPositions[$key])
123+
&& $oldCategoryPositions[$key]['position'] != $newCategoryPosition['position']
124+
) {
123125
$result[] = $newCategoryPositions[$key];
124126
unset($oldCategoryPositions[$key]);
125127
}

app/code/Magento/Catalog/Test/Unit/Model/Category/Link/SaveHandlerTest.php

+15
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,21 @@ public function getCategoryDataProvider()
197197
],
198198
[], //affected category_ids
199199
],
200+
[
201+
[3], //model category_ids
202+
[
203+
['category_id' => 3, 'position' => 20],
204+
['category_id' => 4, 'position' => 30],
205+
], // dto category links
206+
[
207+
['category_id' => 3, 'position' => 10],
208+
],
209+
[
210+
['category_id' => 3, 'position' => 20],
211+
['category_id' => 4, 'position' => 30],
212+
],
213+
[3, 4], //affected category_ids
214+
],
200215
];
201216
}
202217

0 commit comments

Comments
 (0)