6

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

那么我的问题是,是否有一个现有的 cron 工作可以做到这一点,或者这是我必须自己设置的?

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

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

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

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

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

4

1 回答 1

9

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

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

于 2014-01-24T21:37:33.557 回答