如何获取Magento索引状态的状态。我想根据状态根据需要以编程方式重建索引。以下代码将重新索引全部,而不考虑状态。如何检查Magento索引状态
我想重建索引,如果只需要。
$indexCollection = Mage::getModel('index/process')->getCollection();
foreach ($indexCollection as $index) {
$index->reindexAll();
}
如何获取Magento索引状态的状态。我想根据状态根据需要以编程方式重建索引。以下代码将重新索引全部,而不考虑状态。如何检查Magento索引状态
我想重建索引,如果只需要。
$indexCollection = Mage::getModel('index/process')->getCollection();
foreach ($indexCollection as $index) {
$index->reindexAll();
}
你可以尝试这样的事情
$myindex = Mage::getSingleton('index/indexer')->getProcessByCode('processcode');
echo $myindex->getStatus();
您可以用这种方式尝试。
for($i=1; $i<=9; $i++){
$process = Mage::getSingleton('index/indexer')->getProcessById($i);
$state = $process->getStatus();
if($state == Mage_Index_Model_Process::STATUS_PENDING){
$process->reindexEverything();
}
}
不是一个好主意,你不知道是否有真正的9索引,并且不对对象执行任何检查以确保它们存在 – Mayers
我认为这将有助于你http://magento.stackexchange.com/questions/5791/check-if-reindexing-is-needed –