Magento data-install script
- by Vladimir Kerkhoff
I'm trying to build a data install script that I use to setup a new webstore. This script creates the categories, pages and static blocks and default settings for the specific shop (we use a multistore setup to host the shops). In our dev/staging setup this scripts runs great and all categories are build without any problem. But on our live system this script fails. After some debugging I found the difference is in the Flat catalog usage on the live systems.
The problem with creating the category with the flat tables enabled is in getting the parent path information based on the parentId given:
$parentCategory = Mage::getModel('catalog/category')->load($parentId);
Without flat categories enabled this gives a correct parentCategory, but with flat categories enabled it gives an empty object.
Why is this behaviour with flat categories enabled?