/** * Tells the core indexer to do a partial reindex * @param Mage_Index_Model_Process $process * @throws Exception */ public function executePartialIndex(Mage_Index_Model_Process $process) { /** @var $resourceModel Mage_Index_Model_Resource_Process */ $resourceModel = Mage::getResourceSingleton('index/process'); if (Mage::getStoreConfigFlag('system/asyncindex/use_transactions')) { $resourceModel->beginTransaction(); } $indexMode = 'schedule'; $pendingMode = 'pending'; //Fallback for 1.6.2 installations > Undefined class constant 'MODE_SCHEDULE' if (true === defined('Mage_Index_Model_Process::MODE_SCHEDULE')) { $indexMode = Mage_Index_Model_Process::MODE_SCHEDULE; $pendingMode = Mage_Index_Model_Process::STATUS_PENDING; } try { $process->setMode($indexMode); $process->indexEvents(); if (count(Mage::getResourceSingleton('index/event')->getUnprocessedEvents($process)) === 0) { $process->changeStatus($pendingMode); } if (Mage::getStoreConfigFlag('system/asyncindex/use_transactions')) { $resourceModel->commit(); } } catch (Exception $e) { if (Mage::getStoreConfigFlag('system/asyncindex/use_transactions')) { $resourceModel->rollBack(); } throw $e; } }
/** * @param Mage_Index_Model_Process $process * * @throws Exception */ protected function _execPartialIndex(Mage_Index_Model_Process $process) { $this->_indexerTransactionBegin(); // MODE_SCHEDULE available in Mage >1.8 $indexMode = true === defined('Mage_Index_Model_Process::MODE_SCHEDULE') ? Mage_Index_Model_Process::MODE_SCHEDULE : 'schedule'; $pendingMode = Mage_Index_Model_Process::STATUS_PENDING; try { $process->setMode($indexMode); $process->indexEvents(); $unProcessedEvents = count(Mage::getResourceSingleton('index/event')->getUnprocessedEvents($process)); if (0 === $unProcessedEvents) { $process->changeStatus($pendingMode); } $this->_indexerTransactionCommit(); } catch (Exception $e) { $this->_indexerTransactionRollBack(); throw $e; } }