Indexing and index processes were introduced in Magento since version 1.4.x. Here is how you can set one index to ‘REINDEX REQUIRED’ with code programmatically.
First you will need to know which specific index you want to set to dirty. By default in 220.127.116.11 these are the options:
process_id: 1, indexer_code: catalog_product_attribute
process_id: 2, indexer_code: catalog_product_price
process_id: 3, indexer_code: catalog_url
process_id: 4, indexer_code: catalog_product_flat
process_id: 5, indexer_code: catalog_category_flat
process_id: 6, indexer_code: catalog_category_product
process_id: 7, indexer_code: catalogsearch_stock
process_id: 8, indexer_code: cataloginventory_stock
process_id: 9, indexer_code: tag_summary
In order to mark one of them as ‘REINDEX REQUIRED’, use one of the two methods to select the specific index. You can choose by ID or by CODE.
$process = Mage::getSingleton('index/indexer')->getProcessById(1);
$process = Mage::getSingleton('index/indexer')->getProcessByCode('catalog_product_attribute');
Now we need to change the status of this process:
Alternatively, we can do it all at once: