Skip to content

Flat Categories enabled

Nils Preuß edited this page Sep 17, 2013 · 2 revisions

There is a problem if the store has flat categories enabled. The whole category interface changes in a way import is not working any more. My first try to fix it in the importer did not work out and so i came up with this workaround: At the begin of my importer script i have changed my normal Mage::app() to the following to disable flat categories during import.

Mage::app('admin', 'store', array('global_ban_use_cache' =>true));
if (Mage::helper('catalog/category_flat')->isEnabled()) {
    Mage::getModel('core/config')->saveConfig('catalog/frontend/flat_catalog_category', 0);
    $switched = true;
}
Mage::getConfig()->getOptions()->setData('global_ban_use_cache', false);
Mage::app()->baseInit(array());
Mage::getConfig()->loadModules()->loadDb()->saveCache();

after my categorie import i added:

if ($switched) {
    Mage::getModel('core/config')->saveConfig('catalog/frontend/flat_catalog_category', 1);
}

Because i use a simple script for importing instead of a full extension/class solution i cannot use __destruct() for clean shutdown and resetting of the config values.

Clone this wiki locally