问题
Magento 1.13 added partial indexing for most indexes along with the ability to defer the indexing process to a cron job that runs asynchronously.
My question then is, is there an existing cron job that does this or is this something I have to set up myself?
The documentation is not clear on this: http://www.magentocommerce.com/knowledge-base/entry/ee113-indexing#reindex-options
- Update when scheduled to schedule reindexing using your Magento cron job.
- The change occurs either within the minute or according to your cron job schedule.
This leads me to believe it's an existing process that runs every time the cron runs.
I see the index cleaner schedule, but that only appears to clear out old records in the change log tables. It does not seem to actually do any indexing.
I can't seem to find a cron job in core code that runs these indexes.
回答1:
I think I found it. 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;
}
This runs "always" on every cron execution. It runs full reindexes for the indexes that need and and processes the changelog for those that don't.
来源:https://stackoverflow.com/questions/21321225/when-does-automatic-partial-reindexing-actually-run-in-magento-ee-1-13