Skip to content

Commit 168701c

Browse files
author
Oleksii Korshenko
committed
MAGETWO-64403: [GitHub] [PR] Sorting the returning array by the position of the linked products. Fix for magento2/issues/8392 #8467
- Merge Pull Request #8467 from kirashet666/magento2:develop
2 parents c7fff61 + 0002f6d commit 168701c

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

app/code/Magento/Catalog/Model/ProductLink/CollectionProvider.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,21 @@ public function getCollection(\Magento\Catalog\Model\Product $product, $type)
4848
$products = $this->providers[$type]->getLinkedProducts($product);
4949
$converter = $this->converterPool->getConverter($type);
5050
$output = [];
51+
$realoutput = [];
5152
foreach ($products as $item) {
5253
$output[$item->getId()] = $converter->convert($item);
5354
}
54-
return $output;
55+
foreach ($output as $item) {
56+
$itemPosition = $item["position"];
57+
if (!isset($realoutput[$itemPosition])) {
58+
$realoutput[$itemPosition] = $item;
59+
}
60+
else {
61+
$newPosition = $itemPosition+1;
62+
$realoutput[$newPosition] = $item;
63+
}
64+
}
65+
ksort($realoutput);
66+
return $realoutput;
5567
}
5668
}

0 commit comments

Comments
 (0)