Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Stop Indexing in Magento
<?php
class Klasse {
public static function switchIndexingOff() {
$processes = Mage::getSingleton('index/indexer')->getProcessesCollection();
$processes->walk('setMode', array(Mage_Index_Model_Process::MODE_MANUAL));
$processes->walk('save');
}
public static function rebuildIndices() {
$processes = Mage::getSingleton('index/indexer')->getProcessesCollection();
$processes->walk('reindexAll');
$processes->walk('setMode', array(Mage_Index_Model_Process::MODE_REAL_TIME));
$processes->walk('save');
}
}
@paales

This comment has been minimized.

Show comment Hide comment
@paales

paales Dec 16, 2012

I like how you used the walk method, should be used more often in Magento (low memory etc.). Cool thing with the walk method you can pass an anonymous function into it, like so:

<?php
$collection->walk(function($item, $secondArgument){
    //do stuff here
}, array('secondArgument'));

paales commented Dec 16, 2012

I like how you used the walk method, should be used more often in Magento (low memory etc.). Cool thing with the walk method you can pass an anonymous function into it, like so:

<?php
$collection->walk(function($item, $secondArgument){
    //do stuff here
}, array('secondArgument'));
@omargits

This comment has been minimized.

Show comment Hide comment
@omargits

omargits Jan 19, 2015

can you tell me how can i implement this in my project.

can you tell me how can i implement this in my project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment