<?php
### Magento programatically refresh reindexing indexes
function refreshAllIndexes() {
/* @var $indexCollection Mage_Index_Model_Resource_Process_Collection */
$indexCollection = Mage::getModel('index/process')->getCollection();
foreach ($indexCollection as $index) {
/* @var $index Mage_Index_Model_Process */
$index->reindexAll();
#echo '<pre>' . print_r($index->debug(), TRUE) . '</pre>';
}
}
/**
* catalog_product_attribute Product Attributes
* catalog_product_price Product Prices
* catalog_url Catalog URL Rewrites
* catalog_product_flat Product Flat Data
* catalog_category_flat Category Flat Data
* catalog_category_product Category Products
* catalogsearch_fulltext Catalog Search Index
* cataloginventory_stock Stock Status
* tag_summary Tag Aggregation Data
* targetrule Target Rules
*/
function refreshIndex($indexName) {
$process = Mage::getModel('index/indexer')->getProcessByCode($indexName);
$process->reindexAll();
}
?>
Reference:
http://www.kennydeckers.com/magento-programatically-reindexing-indexes/
No comments:
Post a Comment