コード例 #1
0
ファイル: Indexer.php プロジェクト: aiesh/magento2
 /**
  * Run application
  *
  * @return \Magento\Framework\App\ResponseInterface
  */
 public function launch()
 {
     /* Clean reports */
     $directory = $this->_filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::ROOT_DIR);
     $path = $directory->getRelativePath($this->_reportDir);
     if ($directory->isExist($path)) {
         $directory->delete($path);
     }
     /* Run all indexer processes */
     /** @var $indexer \Magento\Index\Model\Indexer */
     $indexer = $this->_indexerFactory->create();
     /** @var $process \Magento\Index\Model\Process */
     foreach ($indexer->getProcessesCollection() as $process) {
         if ($process->getIndexer()->isVisible()) {
             $process->reindexEverything();
         }
     }
     $this->_response->setCode(0);
     return $this->_response;
 }
コード例 #2
0
ファイル: Process.php プロジェクト: aiesh/magento2
 /**
  * Get Indexer strategy object
  *
  * @throws \Magento\Framework\Model\Exception
  * @return \Magento\Index\Model\IndexerInterface
  */
 public function getIndexer()
 {
     if ($this->_currentIndexer === null) {
         $name = $this->_getData('indexer_code');
         if (!$name) {
             throw new \Magento\Framework\Model\Exception(__('Indexer name is not defined.'));
         }
         $indexerConfiguration = $this->_indexerConfig->getIndexer($name);
         if (!$indexerConfiguration || empty($indexerConfiguration['instance'])) {
             throw new \Magento\Framework\Model\Exception(__('Indexer model is not defined.'));
         }
         $indexerModel = $this->_indexerFactory->create($indexerConfiguration['instance']);
         if ($indexerModel instanceof \Magento\Index\Model\Indexer\AbstractIndexer) {
             $this->_currentIndexer = $indexerModel;
         } else {
             throw new \Magento\Framework\Model\Exception(__('Indexer model should extend \\Magento\\Index\\Model\\Indexer\\Abstract.'));
         }
     }
     return $this->_currentIndexer;
 }