Last active
November 1, 2019 11:55
-
-
Save hslatman/16c1ea0c29c6e38475fa to your computer and use it in GitHub Desktop.
Custom Magento re-indexing script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/****************************************************************************************************************** | |
* Source: http://www.emvee-solutions.com/blog/magento-custom-reindex-script/ | |
* | |
* Custom Magento re-indexing script | |
******************************************************************************************************************/ | |
//Place this file in your Magento root folder, or modify the require once to match your directory. | |
//increase execution time to 900seconds for larger stores | |
ini_set('max_execution_time', 900); | |
//require Magento | |
require_once 'app/Mage.php'; | |
$app = Mage::app('admin'); | |
umask(0); | |
//set error reporting | |
error_reporting(E_ALL & ~E_NOTICE); | |
Mage::setIsDeveloperMode(true); | |
//array of indexes - You probably won`t use them all, modify this for your needs | |
$indexcodes = array("cataloginventory_stock","catalogsearch_fulltext","catalog_category_flat","catalog_category_product", | |
"catalog_product_attribute","catalog_product_attribute","catalog_product_flat","catalog_product_price", | |
"catalog_url","groupscatalog2_category","groupscatalog2_product","tag_summary"); | |
//reindex | |
foreach ($indexcodes as $index) { | |
print 'Reindex ' . $index; | |
try { | |
$process = Mage::getModel('index/indexer')->getProcessByCode($index); | |
$process->reindexAll(); | |
} catch(Exception $e) { | |
echo 'Oops, error while reindexing index' . $index . '<br/>'; | |
print($e->getMessage()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Extremely usefull. I could find what was causing error. Thank you.