I tried locking my indexer programmatically with this code as I used to do:

$indexer = Mage::getSingleton('index/indexer');

I noticed that my indexer didn't get locked and when i went looking in the core files I saw it was deprecated. Is there any other way to lock the indexer? I looked into it and didn't exactly see one.


You could just touch the lock file.

<?php touch('BP.DS.'var'.DS.'locks'.DS.'index_process_1.lock')


touch /home/path/public_html/var/locks/index_process_1.lock

This is obviously a low quality solution - but if you wanted to perform this action peripherally to Magento (eg. from a bash script, it would be suitable).

Otherwise, the methods you need are in Mage_Index_Model_Process

Such as isLocked(), lockAndBlock(), and unlock()

Assuming your module extends said class, you need only declare

const PROCESS_ID = 'my_indexer'

And use the methods as appropriate

  • Don't really agree with creating them with touch as i rather go the Magento way but lockAndBlock did the trick :) Feb 1 '13 at 9:42

You can lock each index process individually:

  • Does it return true if lock succeeds and false if not?
    – snh_nl
    Jan 24 '19 at 11:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.