Пример #1
0
 /**
  * {@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('.');
             }
         }
     }
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     $this->attributeSetup->run();
     $this->categorySetup->run();
     $this->productSetup->run();
     $this->postInstaller->addSetupResource($this->productLinkSetup);
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     $this->postInstaller->addSetupResource($this->cmsBlockSetup, 20);
 }
Пример #4
0
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     $this->postInstaller->addSetupResource($this->reviewSetup);
 }
Пример #5
0
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     $this->pageSetup->run();
     $this->postInstaller->addSetupResource($this->blockSetup);
 }