【问题标题】:When does automatic partial reindexing actually run in Magento EE 1.13?Magento EE 1.13 中何时实际运行自动部分重新索引?
【发布时间】:2014-02-14 18:30:55
【问题描述】:

Magento 1.13 为大多数索引添加了部分索引以及将索引过程推迟到异步运行的 cron 作业的能力。

那么我的问题是,是否有现有的 cron 作业可以执行此操作,或者这是我必须自己设置的?

文档对此并不清楚: http://www.magentocommerce.com/knowledge-base/entry/ee113-indexing#reindex-options

  • 按计划更新以使用您的 Magento cron 作业安排重新索引。
  • 更改会在一分钟内或根据您的 cron 作业计划发生。

这让我相信这是一个现有的进程,每次 cron 运行时都会运行。

我看到了索引清理计划,但这似乎只是清除了更改日志表中的旧记录。它似乎实际上并没有做任何索引。

我似乎无法在运行这些索引的核心代码中找到一个 cron 作业。

【问题讨论】:

    标签: magento indexing magento-1.13


    【解决方案1】:

    我想我找到了。企业刷新索引

    <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 执行时“始终”运行。它为需要的索引运行完整的重新索引,并为不需要的索引处理更改日志。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-12-23
      • 1970-01-01
      • 2021-01-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-05
      • 2014-01-27
      相关资源
      最近更新 更多