コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     $this->logger->log('Installing CMS blocks:');
     if (!$this->deployHelper->isMediaPresent()) {
         $this->logger->log('Sample Data Media was not installed. Skipping CMS blocks installation');
         return;
     }
     foreach ($this->fixtures as $file) {
         /** @var \Magento\SampleData\Helper\Csv\Reader */
         $fileName = $this->fixtureHelper->getPath($file);
         $csvReader = $this->csvReaderFactory->create(['fileName' => $fileName, 'mode' => 'r']);
         foreach ($csvReader as $row) {
             $data = $this->converter->convertRow($row);
             $data = $data['block'];
             /** @var \Magento\Cms\Model\Block $cmsBlock */
             $cmsBlock = $this->blockFactory->create();
             $cmsBlock->getResource()->load($cmsBlock, $data['identifier']);
             if ($cmsBlock->getId()) {
                 continue;
             }
             $cmsBlock->addData($data);
             $cmsBlock->setStores([\Magento\Store\Model\Store::DEFAULT_STORE_ID]);
             $cmsBlock->setIsActive(1);
             $cmsBlock->save();
             $cmsBlock->unsetData();
             $this->logger->logInline('.');
         }
     }
 }
コード例 #2
0
 /**
  * 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());
     }
 }
コード例 #3
0
ファイル: Category.php プロジェクト: ktplKunj/TestMagento
 /**
  * @return bool
  */
 protected function isMediaInstalled()
 {
     if (!isset($this->mediaInstalled)) {
         $this->mediaInstalled = $this->deployHelper->isMediaPresent();
     }
     return $this->mediaInstalled;
 }
コード例 #4
0
ファイル: Block.php プロジェクト: ktplKunj/TestMagento
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     $this->logger->log('Installing CMS blocks:');
     if (!$this->deployHelper->isMediaPresent()) {
         $this->logger->log('Sample Data Media was not installed. Skipping CMS blocks installation');
         return;
     }
     foreach ($this->fixtures as $file) {
         /** @var \Magento\SampleData\Helper\Csv\Reader */
         $fileName = $this->fixtureHelper->getPath($file);
         $csvReader = $this->csvReaderFactory->create(['fileName' => $fileName, 'mode' => 'r']);
         foreach ($csvReader as $row) {
             $data = $this->converter->convertRow($row);
             $cmsBlock = $this->saveCmsBlock($data['block']);
             $cmsBlock->unsetData();
             $this->logger->logInline('.');
         }
     }
 }
コード例 #5
0
ファイル: Product.php プロジェクト: ktplKunj/TestMagento
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     if (!$this->deployHelper->isMediaPresent()) {
         $this->logger->log('Sample Data Media was not installed. Skipping downloadable product installation');
         return;
     }
     $this->gallery->setFixtures(['Downloadable/images_products_training_video.csv']);
     $downloadableFiles = ['Downloadable/downloadable_data_training_video_download.csv'];
     foreach ($downloadableFiles as $downloadableFile) {
         $downloadableFileName = $this->fixtureHelper->getPath($downloadableFile);
         $csvDownloadableReader = $this->csvReaderFactory->create(['fileName' => $downloadableFileName, 'mode' => 'r']);
         foreach ($csvDownloadableReader as $downloadableRow) {
             $sku = $downloadableRow['product_sku'];
             if (!isset($this->downloadableData[$sku])) {
                 $this->downloadableData[$sku] = [];
             }
             $this->downloadableData[$sku] = $this->converter->getDownloadableData($downloadableRow, $this->downloadableData[$sku]);
             $this->downloadableData[$sku]['sample'] = $this->converter->getSamplesInfo();
         }
     }
     parent::run();
 }