Magento 1.13 为大多数索引添加了部分索引,并能够将索引过程推迟到异步运行的 cron 作业。
我的问题是,是否有现有的 cron 作业可以执行此操作,或者这是我必须自己设置的东西?
文档对此并不清楚:http://www.magentocommerce.com/knowledge-base/entry/ee113-indexing#reindex-options http://www.magentocommerce.com/knowledge-base/entry/ee113-indexing#reindex-options
-
按预定时间更新使用 Magento cron 作业安排重新索引。
- 更改会在一分钟内发生或根据您的 cron 作业计划发生。
这让我相信这是一个现有的进程,每次 cron 运行时都会运行。
我看到索引清理计划,但这似乎只是清除更改日志表中的旧记录。它似乎实际上并没有做任何索引。
我似乎无法在运行这些索引的核心代码中找到 cron 作业。
我想我找到了。企业刷新索引
<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 执行时“始终”运行。它为需要的索引运行完整的重新索引,并为不需要的索引处理更改日志。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)