/** * {@inheritdoc} */ public function run() { $this->attributeSetup->run(); $this->categorySetup->run(); $this->productSetup->run(); $this->postInstaller->addSetupResource($this->productLinkSetup); }
/** * {@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\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('.'); } } } }
/** * Run installation in context of the specified admin user * * @param $userName * @param array $modules * @return void * @throws \Exception */ public function run($userName, array $modules = []) { set_time_limit(0); /** @var \Magento\User\Model\User $user */ $user = $this->userFactory->create()->loadByUsername($userName); if (!$user->getId()) { throw new \Exception('Invalid admin user provided'); } $this->state->start(); $this->session->setUser($user); $this->deploy->run(); $resources = $this->initResources($modules); $this->state->clearErrorFlag(); try { foreach ($this->moduleList->getNames() as $moduleName) { if (isset($resources[$moduleName])) { $resourceType = $resources[$moduleName]; $this->setupFactory->create($resourceType)->run(); $this->postInstaller->addModule($moduleName); } } $this->session->unsUser(); $this->postInstaller->run(); $this->state->finish(); } catch (\Exception $e) { $this->state->setError(); $this->logger->log($e->getMessage()); } }
/** * {@inheritdoc} */ public function run() { $this->logger->log('Installing related product rules:'); $this->postInstaller->removeSetupResourceType('Magento\\SampleData\\Module\\Catalog\\Setup\\ProductLink'); $entityFileAssociation = [\Magento\TargetRule\Model\Rule::RELATED_PRODUCTS => 'related', \Magento\TargetRule\Model\Rule::UP_SELLS => 'upsell', \Magento\TargetRule\Model\Rule::CROSS_SELLS => 'crosssell']; foreach ($entityFileAssociation as $linkTypeId => $linkType) { $fileName = 'TargetRule/' . $linkType . '.csv'; $fileName = $this->fixtureHelper->getPath($fileName); if (!$fileName) { continue; } /** @var \Magento\SampleData\Helper\Csv\Reader $csvReader */ $csvReader = $this->csvReaderFactory->create(['fileName' => $fileName, 'mode' => 'r']); foreach ($csvReader as $row) { /** @var \Magento\TargetRule\Model\Rule $rule */ $rule = $this->ruleFactory->create(); if ($rule->getResourceCollection()->addFilter('name', $row['name'])->getSize() > 0) { continue; } $sourceCategory = $this->getConditionFromCategory(array_filter(explode("\n", $row['source_category'])), 'Rule'); $targetCategory = $this->getConditionFromCategory(array_filter(explode("\n", $row['target_category'])), 'Actions'); if (!$sourceCategory || !$targetCategory) { continue; } $targetCategory['value_type'] = TargetRuleActionAttributes::VALUE_TYPE_CONSTANT; $ruleConditions = $this->createConditions($sourceCategory, $targetCategory); $rule->setName($row['name'])->setApplyTo($linkTypeId)->setIsActive(1)->setSortOrder(0)->setPositionsLimit(empty($row['limit']) ? 0 : $row['limit']); $rule->loadPost($ruleConditions); $rule->save(); $this->logger->logInline('.'); } } }
/** * {@inheritdoc} */ public function run() { $this->postInstaller->addSetupResource($this->cmsBlockSetup, 20); }
/** * {@inheritdoc} */ public function run() { $this->pageSetup->run(); $this->postInstaller->addSetupResource($this->blockSetup); }
/** * {@inheritdoc} */ public function run() { $this->postInstaller->addSetupResource($this->ruleSetup); }
/** * {@inheritdoc} */ public function run() { $this->postInstaller->addSetupResource($this->wishlistSetup); }
/** * {@inheritdoc} */ public function run() { $this->postInstaller->removeSetupResourceType('Magento\\SampleData\\Module\\Wishlist\\Setup\\Wishlist'); $this->postInstaller->addSetupResource($this->wishlistSetup); }