/**
  * {@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
 /**
  * @return bool
  */
 protected function isMediaInstalled()
 {
     if (!isset($this->mediaInstalled)) {
         $this->mediaInstalled = $this->deployHelper->isMediaPresent();
     }
     return $this->mediaInstalled;
 }
예제 #3
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);
             $cmsBlock = $this->saveCmsBlock($data['block']);
             $cmsBlock->unsetData();
             $this->logger->logInline('.');
         }
     }
 }
예제 #4
0
 /**
  * {@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();
 }