/** * {@inheritdoc} */ public function run() { $this->logger->log('Installing product links:'); $entityFileAssociation = ['related', 'upsell', 'crosssell']; foreach ($this->postInstaller->getInstalledModuleList() as $moduleName) { foreach ($entityFileAssociation as $linkType) { $fileName = substr($moduleName, strpos($moduleName, "_") + 1) . '/Links/' . $linkType . '.csv'; $fileName = $this->fixtureHelper->getPath($fileName); if (!$fileName) { continue; } /** @var \Magento\Tools\SampleData\Helper\Csv\ReaderFactory $csvReader */ $csvReader = $this->csvReaderFactory->create(['fileName' => $fileName, 'mode' => 'r']); foreach ($csvReader as $row) { /** @var \Magento\Catalog\Model\Product $product */ $product = $this->productFactory->create(); $productId = $product->getIdBySku($row['sku']); if (!$productId) { continue; } $product->setId($productId); $links = [$linkType => []]; foreach (explode("\n", $row['linked_sku']) as $linkedProductSku) { $linkedProductId = $product->getIdBySku($linkedProductSku); if ($linkedProductId) { $links[$linkType][$linkedProductId] = []; } } $this->linksInitializer->initializeLinks($product, $links); $product->getLinkInstance()->saveProductRelations($product); $this->logger->logInline('.'); } } } }
/** * {@inheritdoc} */ public function run() { $this->attributeSetup->run(); $this->categorySetup->run(); $this->productSetup->run(); $this->postInstaller->addSetupResource($this->productLinkSetup); }
/** * {@inheritdoc} */ public function run() { $this->postInstaller->addSetupResource($this->cmsBlockSetup, 20); }
/** * {@inheritdoc} */ public function run() { $this->postInstaller->addSetupResource($this->reviewSetup); }
/** * {@inheritdoc} */ public function run() { $this->pageSetup->run(); $this->postInstaller->addSetupResource($this->blockSetup); }