本文整理汇总了PHP中Mage_Index_Model_Process::setMode方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Index_Model_Process::setMode方法的具体用法?PHP Mage_Index_Model_Process::setMode怎么用?PHP Mage_Index_Model_Process::setMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Index_Model_Process
的用法示例。
在下文中一共展示了Mage_Index_Model_Process::setMode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executePartialIndex
/**
* 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;
}
}
示例2: _execPartialIndex
/**
* @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;
}
}