コード例 #1
0
 /**
  * Regenerate indexes for all invalid indexers
  *
  * @return void
  */
 public function reindexAllInvalid()
 {
     foreach (array_keys($this->config->getIndexers()) as $indexerId) {
         $indexer = $this->indexerFactory->create();
         $indexer->load($indexerId);
         if ($indexer->isInvalid()) {
             $indexer->reindexAll();
         }
     }
 }
コード例 #2
0
ファイル: Shell.php プロジェクト: shabbirvividads/magento2
 /**
  * Parses string with indexers and return array of indexer instances
  *
  * @param string $string
  * @return IndexerInterface[]
  */
 protected function parseIndexerString($string)
 {
     $indexers = [];
     if ($string == 'all') {
         /** @var Indexer[] $indexers */
         $indexers = $this->indexersFactory->create()->getItems();
     } elseif (!empty($string)) {
         $codes = explode(',', $string);
         foreach ($codes as $code) {
             $indexer = $this->indexerFactory->create();
             try {
                 $indexer->load($code);
                 $indexers[] = $indexer;
             } catch (\Exception $e) {
                 echo 'Warning: Unknown indexer with code ' . trim($code) . PHP_EOL;
                 $this->hasErrors = true;
             }
         }
     }
     return $indexers;
 }
コード例 #3
0
 /**
  * Constructor
  *
  * @param IndexerFactory  $indexerFactory
  * @param SearcherFactory $searcherFactory
  */
 public function __construct(IndexerFactory $indexerFactory, SearcherFactory $searcherFactory)
 {
     $this->indexer = $indexerFactory->create()->setIndex($this);
     $this->searcher = $searcherFactory->create()->setIndex($this);
     parent::__construct();
 }