Last active
March 23, 2016 07:38
-
-
Save antoinekociuba/71cab783b690241d7ac7 to your computer and use it in GitHub Desktop.
Disable/Enable EE index updates (might be useful during a script execution to speed it up...)
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 | |
/********************** | |
****** DISABLE ******* | |
**********************/ | |
/** var Mage_Core_Model_Config $config */ | |
$config = Mage::app()->getConfig(); | |
/** | |
* Disable on save index updates | |
*/ | |
$config->saveConfig('index_management/index_options/category_url_rewrite', 0); | |
$config->saveConfig('index_management/index_options/product_url_rewrite', 0); | |
$config->saveConfig('index_management/index_options/redirect_url_rewrite', 0); | |
$config->saveConfig(Enterprise_CatalogSearch_Model_Observer::XML_PATH_LIVE_FULLTEXT_REINDEX_ENABLED, 0); | |
$config->saveConfig(Enterprise_Catalog_Model_Index_Observer_Flat::XML_PATH_LIVE_PRODUCT_REINDEX_ENABLED, 0); | |
$config->saveConfig(Enterprise_Catalog_Model_Index_Observer_Flat::XML_PATH_LIVE_CATEGORY_REINDEX_ENABLED, 0); | |
$config->saveConfig(Enterprise_CatalogInventory_Helper_Index::XML_PATH_LIVE_PRICE_AND_STOCK_REINDEX_ENABLED, 0); | |
$config->saveConfig(Enterprise_Catalog_Model_Index_Observer_Category_Product::XML_PATH_LIVE_CATEGORY_PRODUCT_REINDEX_ENABLED, 0); | |
/** | |
* Refresh config cache | |
*/ | |
$config->reinit(); | |
/** | |
* Lock full reindex process (so 'enterprise_refresh_index' cron will do nothing) | |
* This should be on a try catch, as the cron could be already running when this code is executed | |
*/ | |
Mage::dispatchEvent('shell_reindex_init_process'); | |
/** | |
* | |
* | |
* | |
* | |
* | |
* Do whatever you want! =) | |
* | |
* | |
* | |
* | |
* | |
*/ | |
/********************** | |
**** ENABLE BACK ***** | |
**********************/ | |
/** | |
* Enable on save index updates | |
*/ | |
$config->saveConfig('index_management/index_options/category_url_rewrite', 1); | |
$config->saveConfig('index_management/index_options/product_url_rewrite', 1); | |
$config->saveConfig('index_management/index_options/redirect_url_rewrite', 1); | |
$config->saveConfig(Enterprise_CatalogSearch_Model_Observer::XML_PATH_LIVE_FULLTEXT_REINDEX_ENABLED, 1); | |
$config->saveConfig(Enterprise_Catalog_Model_Index_Observer_Flat::XML_PATH_LIVE_PRODUCT_REINDEX_ENABLED, 1); | |
$config->saveConfig(Enterprise_Catalog_Model_Index_Observer_Flat::XML_PATH_LIVE_CATEGORY_REINDEX_ENABLED, 1); | |
$config->saveConfig(Enterprise_CatalogInventory_Helper_Index::XML_PATH_LIVE_PRICE_AND_STOCK_REINDEX_ENABLED, 1); | |
$config->saveConfig(Enterprise_Catalog_Model_Index_Observer_Category_Product::XML_PATH_LIVE_CATEGORY_PRODUCT_REINDEX_ENABLED, 1); | |
/** | |
* Refresh config cache | |
*/ | |
$config->reinit(); | |
/** | |
* Release full reindex process lock (so cron will be back on track) | |
*/ | |
Mage::dispatchEvent('shell_reindex_finalize_process'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment