예제 #1
0
파일: Setup.php 프로젝트: aiesh/magento2
 /**
  * Sync indexes declarations in config and in DB
  *
  * @return $this
  */
 protected function _syncIndexes()
 {
     $connection = $this->getConnection();
     if (!$connection) {
         return $this;
     }
     $indexCodes = array();
     foreach (array_keys($this->_indexerConfig->getAll()) as $name) {
         $indexCodes[] = $name;
     }
     $table = $this->getTable('index_process');
     $select = $connection->select()->from($table, 'indexer_code');
     $existingIndexes = $connection->fetchCol($select);
     $delete = array_diff($existingIndexes, $indexCodes);
     $insert = array_diff($indexCodes, $existingIndexes);
     if (!empty($delete)) {
         $connection->delete($table, $connection->quoteInto('indexer_code IN (?)', $delete));
     }
     if (!empty($insert)) {
         $insertData = array();
         foreach ($insert as $code) {
             $insertData[] = array('indexer_code' => $code, 'status' => \Magento\Index\Model\Process::STATUS_REQUIRE_REINDEX);
         }
         if (method_exists($connection, 'insertArray') && is_callable([$connection, 'insertArray'])) {
             $connection->insertArray($table, array('indexer_code', 'status'), $insertData);
         }
     }
 }
예제 #2
0
파일: Process.php 프로젝트: aiesh/magento2
 /**
  * Retrieve depend indexer codes
  *
  * @return array
  */
 public function getDepends()
 {
     $depends = $this->getData('depends');
     if (is_null($depends)) {
         $depends = array();
         $indexerConfiguration = $this->_indexerConfig->getIndexer($this->getIndexerCode());
         if ($indexerConfiguration) {
             if (isset($indexerConfiguration['depends']) && is_array($indexerConfiguration['depends'])) {
                 $depends = $indexerConfiguration['depends'];
             }
         }
         $this->setData('depends', $depends);
     }
     return $depends;
 }