I need to easily and quickly check if indexing needs to be done. I have been looking around and have

$process = Mage::getSingleton('index/indexer')->getProcessById();


$process = Mage::getSingleton('index/indexer')->getProcessByCode(<process_code>);

Process Name ID Code 
Product Attributes 1 catalog_product_attribute 
Product Prices 2 catalog_product_price 
Catalog URL Rewrites 3 catalog_url 
Product Flat Data 4 catalog_product_flat 
Category Flat Data 5 catalog_category_flat 
Category Products 6 catalog_category_product 
Catalog Search Index 7 catalogsearch_stock 
Stock Status 8 cataloginventory_stock 
Tag Aggregation Data 9 tag_summary 

but I need to just quickly get the status. Is there a better way?

2 Answers 2

$process = Mage::getSingleton('index/indexer')->getProcessByCode('some_process_code');

By the way it has 3 statuses:

class Mage_Index_Model_Process extends Mage_Core_Model_Abstract
    const XML_PATH_INDEXER_DATA     = 'global/index/indexer';
     * Process statuses
    const STATUS_RUNNING            = 'working';
    const STATUS_PENDING            = 'pending';
    const STATUS_REQUIRE_REINDEX    = 'require_reindex';

    /* class body here*/
  • well that I get, I was more asking if there was another way that was more to the point then me needing to check each one. See it's not that I'm trying to reindex here, it's that I'm going to keep a process in a module I'm making.
    – Quantum
    Jul 17, 2013 at 11:53

"More to the point" can be achieved by filtering the processes collection by the status your looking for:

$indices = Mage::getSingleton('index/indexer')
        ->addFieldToFilter('status', Mage_Index_Model_Process::STATUS_REQUIRE_REINDEX)
if($indices > 0) {
    // something needs to be re-indexed

In case you're looking for what is to be re-indexed you may want to get an array of relevant indices that require further processing:

$indices = Mage::getSingleton('index/indexer')
        ->addFieldToFilter('status', 'require_reindex')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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