Magento - Programmatically Disable Automatic Indexing

杀马特。学长 韩版系。学妹 提交于 2019-11-30 14:11:45

问题


In Magento 1.9 Enterprise (which is essentially the 1.4 Community Edition), what is the correct way to disable the index programmatically so that it wont reindex after every product update?

We have a complex product import procedure, so we can't use the built-in catalog import.


回答1:


Setting the indexer to "manual" mode will prevent it from automatically indexing on save/edit/delete.

In MAGE_ROOT/shell you can find a script called indexer.php that, between others allows you to enable/disable indexers:

php indexer.php --mode-manual catalog_url
php indexer.php --mode-realtime catalog_url

You can have a script that sets all the indexers to manual

If you want to do it programatically, something along the lines should work:

$pCollection = Mage::getSingleton('index/indexer')->getProcessesCollection(); 
foreach ($pCollection as $process) {
  $process->setMode(Mage_Index_Model_Process::MODE_MANUAL)->save();
  //$process->setMode(Mage_Index_Model_Process::MODE_REAL_TIME)->save();
}



回答2:


You may not have to do it programmatically. I had a similar issue where I had about 10 files to import. I couldn't combine as it was a site move and some were dependents on others.

You can turn off automatic index, which if your import script is configured properly will listen to.

It's worth a shot:

System -> Index Management
Check All Items
Change Action to "Change Index Mode"
Select "Manual"
Save

Hope this helps.



来源:https://stackoverflow.com/questions/5420552/magento-programmatically-disable-automatic-indexing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!