Skip to content

Commit cc1a7c9

Browse files
committed
MC-42793: UpSell Products in the product admin are not displaying in the position that they are saved in
- Fix cross-sel/up-sell/related products are not ordered by their positions sometimes
1 parent 39e1300 commit cc1a7c9

File tree

1 file changed

+7
-1
lines changed
  • app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier

1 file changed

+7
-1
lines changed

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Related.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,17 @@ public function modifyData(array $data)
205205

206206
foreach ($this->getDataScopes() as $dataScope) {
207207
$data[$productId]['links'][$dataScope] = [];
208+
$linkItems = [];
208209
foreach ($this->productLinkRepository->getList($product) as $linkItem) {
209210
if ($linkItem->getLinkType() !== $dataScope) {
210211
continue;
211212
}
212-
213+
$linkItems[] = $linkItem;
214+
}
215+
usort($linkItems, function ($a, $b) {
216+
return $a->getPosition() <=> $b->getPosition();
217+
});
218+
foreach ($linkItems as $linkItem) {
213219
/** @var \Magento\Catalog\Model\Product $linkedProduct */
214220
$linkedProduct = $this->productRepository->get(
215221
$linkItem->getLinkedProductSku(),

0 commit comments

Comments
 (0)