Change config during runtime

Sometimes you need to change the Magento configuration during runtime. For example this is the way to temporarily disable the category flat tables

<?php
Mage::app()->getCacheInstance()->banUse('config'); //better switch of config cache
Mage::app()->getStore()->setConfig('catalog/frontend/flat_catalog_category', "0");

// ... Do wired stuff ...

Mage::app()->getStore()->setConfig('catalog/frontend/flat_catalog_category', "1");

Attention: You have to reindex categories afterwards!!!

Leave a Reply

Your email address will not be published.

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.