Skip to content

Commit ede8248

Browse files
committed
MAGETWO-94218: Data from module ProductLinksSampleData is not installed
1 parent 2cfe2c1 commit ede8248

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

app/code/Magento/ProductLinksSampleData/Model/ProductLink.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,14 @@ public function install(array $related, array $upsell, array $crosssell)
9494
$product->setId($productId);
9595
$product->setSku($data['sku']);
9696
$links = $this->productLinkRepository->getList($product);
97-
$linkedProductSkus = explode("\n", $data['linked_sku']);
98-
foreach ($linkedProductSkus as $linkedProductSku) {
97+
$linkedSkusByType = array_fill_keys(array_keys($linkTypes), []);
98+
foreach ($links as $link) {
99+
$linkedSkusByType[$link->getLinkType()][] = $link->getLinkedProductSku();
100+
}
101+
102+
foreach (explode("\n", $data['linked_sku']) as $linkedProductSku) {
99103
$linkedProductId = $product->getIdBySku($linkedProductSku);
100-
if (!$linkedProductId) {
104+
if (!$linkedProductId || in_array($linkedProductSku, $linkedSkusByType[$linkType])) {
101105
continue;
102106
}
103107

0 commit comments

Comments
 (0)