I am looping trough 50.000 products. Most with linked items. But it takes forever. It can only handle 1-3 products/second? Is their a faster way than this?
ProductLinkInterfaceFactory $productLink,
ProductRepositoryInterface $productRepository,
*Loop*
$linkData = [];
$productLink = $this->productLink->create();
$productLink->setSku($SKU)
->setLinkedProductSku($item)
->setPosition($key)
->setLinkType('crosssell');
$linkData[] = $productLink;
$productLink = $this->productLink->create();
$productLink->setSku($SKU)
->setLinkedProductSku($item)
->setPosition($key)
->setLinkType('upsell');
$linkData[] = $productLink;
$product = $this->productRepository->get($SKU);
$product->setProductLinks($linkData);
$product->save();