2014-01-23 32 views
6

Magento 1.13爲大多數索引添加了部分索引,並且能夠將索引進程推遲到異步運行的cron作業。什麼時候在Magento EE 1.13中實際運行自動部分重新索引?

我的問題是,有沒有這樣做的現有cron工作,或者這是我必須建立自己的東西?定何時安排使用你的Magento cron作業重新索引 http://www.magentocommerce.com/knowledge-base/entry/ee113-indexing#reindex-options

  • 更新:

    的文檔不明確這一點。

  • 更改發生在分鐘內或根據您的cron工作計劃。

這使我相信這是一個現有的過程,每次運行cron時都會運行。

我看到索引清理計劃,但只顯示清除更改日誌表中的舊記錄。它似乎沒有實際做任何索引。

我似乎無法在運行這些索引的核心代碼中找到cron作業。

回答

9

我想我找到了。 enterprise_refresh_index

<enterprise_refresh_index> 
    <schedule> 
     <cron_expr>always</cron_expr> 
    </schedule> 
    <run> 
     <model>enterprise_index/observer::refreshIndex</model> 
    </run> 
</enterprise_refresh_index> 

public function refreshIndex(Mage_Cron_Model_Schedule $schedule) 
{ 
    /** @var $helper Enterprise_Index_Helper_Data */ 
    $helper = Mage::helper('enterprise_index'); 

    /** @var $lock Enterprise_Index_Model_Lock */ 
    $lock = Enterprise_Index_Model_Lock::getInstance(); 

    if ($lock->setLock(self::REINDEX_FULL_LOCK)) { 

     /** 
     * Workaround for fatals and memory crashes: Invalidating indexers that are in progress 
     * Successful lock setting is considered that no other full reindex processes are running 
     */ 
     $this->_invalidateInProgressIndexers(); 

     $client = Mage::getModel('enterprise_mview/client'); 
     try { 

      //full re-index 
      $inactiveIndexes = $this->_getInactiveIndexersByPriority(); 
      $rebuiltIndexes = array(); 
      foreach ($inactiveIndexes as $inactiveIndexer) { 
       $tableName = (string)$inactiveIndexer->index_table; 
       $actionName = (string)$inactiveIndexer->action_model->all; 
       $client->init($tableName); 
       if ($actionName) { 
        $client->execute($actionName); 
        $rebuiltIndexes[] = $tableName; 
       } 
      } 

      //re-index by changelog 
      $indexers = $helper->getIndexers(true); 
      foreach ($indexers as $indexerName => $indexerData) { 
       $indexTable = (string)$indexerData->index_table; 
       $actionName = (string)$indexerData->action_model->changelog; 
       $client->init($indexTable); 
       if (isset($actionName) && !in_array($indexTable, $rebuiltIndexes)) { 
        $client->execute($actionName); 
       } 
      } 

     } catch (Exception $e) { 
      $lock->releaseLock(self::REINDEX_FULL_LOCK); 
      throw $e; 
     } 

     $lock->releaseLock(self::REINDEX_FULL_LOCK); 
    } 

    return $this; 
} 

這將運行 「永遠」 在每一個cron的執行。它爲需要的索引運行完整的重建索引,併爲那些不需要的索引處理更改日誌。

相關問題