I want to set an cronjob for reindexing some indexes, but preferably not all.
- First of all, how would I set one up for all?
- And if possible how to I exclude a specific index?
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityTo reindex all indexes:
php -f indexer.php reindexall
To retrieve a full list of available indexes:
php -f indexer.php info
Then specify the type of index you would like to reindex like so:
php indexer.php --reindex catalog_product_attribute
Below is the full list of individual commands:
php indexer.php --reindex catalog_product_price
php indexer.php --reindex catalog_url
php indexer.php --reindex catalog_product_flat
php indexer.php --reindex catalog_category_flat
php indexer.php --reindex catalog_category_product
php indexer.php --reindex catalogsearch_fulltext
php indexer.php --reindex cataloginventory_stock
php indexer.php --reindex tag_summary
To retrieve a full list of indexer commands:
php -f indexer.php help
You can set below code in one .sh file for specific index and set this sh file in to your cron tab
echo "catalog_product_attribute"
date
php /YOurMagentoDir/shell/indexer.php --reindex catalog_product_attribute
hope this will work for you.
You can follow this thread for the reindexing issue,
https://stackoverflow.com/questions/14827996/magento-reindexing-price-programmatically
You can set the file you create for cron. Set cron with defined interval from the cpanel.
For all indexs:
$processes = $indexer->getProcessesCollection();
foreach ($processes as $process) {
$process->reindexEverything();
}
You can ask if it need to be reindexed by :
if ($process->getStatus == Mage_Index_Model_Process::STATUS_REQUIRE_REINDEX)
For some indexs:
$index_codes = array('catalog_product_attribute', 'catalog_product_price', 'cataloginventory_stock');
foreach($index_codes as $code){
$process = Mage::getSingleton('index/indexer')->getProcessByCode($code);
$process -> reindexEverything();
}
Good Luck!