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!!!

Disable usage of flat tables for categories via code

<?php $oCategoryCollection = Mage::getModel(‘catalog/category’, array(‘disable_flat’ => true))->getCollection(); That’s it! Now the “normal” entity tables are used. That work’s because the field disable_flat decides what kind of collection is loaded in the constructor of Mage_Catalog_Model_Category: <?php class Mage_Catalog_Model_Category extends Mage_Catalog_Model_Abstract { //… /** * Initialize resource mode * * @return void */ protected function _construct() { // […]