Magento 1 Categories, with and without Flat Tables

Sometimes Magento leaves you wondering, “WHY!?!?!?!?!?”


If flat categories are enabled, and you want all the children of a parent category, do this:

$children = Mage::getModel('catalog/category')->load($theCategoryIdHere)->getChildrenCategories();

If they are not enabled, do this:

$children = Mage::getModel('catalog/category')->getCategories($theCategoryIdHere);

How do you know if they are enabled?

if (Mage::helper('catalog/category_flat')->isEnabled()) {}

Also, getChildrenCategories() on the flat category list returns the category objects in the same order you find them in the admin category manager. However,


returns a comma separated string of child category ids in numerical order.