Exemple #1
0
 /**
  * Parses string with indexers and return array of indexer instances
  *
  * @param string $string
  * @return array
  */
 protected function _parseIndexerString($string)
 {
     $processes = array();
     if ($string == 'all') {
         $collection = $this->_indexer->getProcessesCollection();
         foreach ($collection as $process) {
             $processes[] = $process;
         }
     } else {
         if (!empty($string)) {
             $codes = explode(',', $string);
             foreach ($codes as $code) {
                 $process = $this->_indexer->getProcessByCode(trim($code));
                 if (!$process) {
                     echo 'Warning: Unknown indexer with code ' . trim($code) . "\n";
                     $this->_hasErrors = true;
                 } else {
                     $processes[] = $process;
                 }
             }
         }
     }
     return $processes;
 }
Exemple #2
0
 /**
  * Reindex all data what this process responsible is
  * Check and using depends processes
  *
  * @return $this|void
  */
 public function reindexEverything()
 {
     if ($this->getData('runed_reindexall')) {
         return $this;
     }
     $this->setForcePartialReindex($this->getStatus() == self::STATUS_PENDING && $this->_eventRepository->hasUnprocessed($this));
     if ($this->getDepends()) {
         foreach ($this->getDepends() as $code) {
             $process = $this->_indexer->getProcessByCode($code);
             if ($process) {
                 $process->reindexEverything();
             }
         }
     }
     $this->setData('runed_reindexall', true);
     return $this->reindexAll();
 }
Exemple #3
0
 /**
  * Invalidate indexes by process codes.
  *
  * @return $this
  */
 public function invalidateIndex()
 {
     $relatedIndexers = $this->_importConfig->getRelatedIndexers($this->getEntity());
     if (empty($relatedIndexers)) {
         return $this;
     }
     foreach ($relatedIndexers as $indexer) {
         $indexProcess = $this->_indexer->getProcessByCode($indexer);
         if ($indexProcess) {
             $indexProcess->changeStatus(\Magento\Index\Model\Process::STATUS_REQUIRE_REINDEX);
         }
     }
     return $this;
 }