I have been trying to get children categories from certain category. And recently i discovered that some child categories are not displaying. After several hours of trying to figure out what's wrong. I found that in MySQL database those categories not displaying who has column level equal to 3. Witch is fine because my category tree is:


And what is strange that when i set level to 0 in Mysql database in catalog_category_entity table, categories start to display... My code is:

$publisher_cat_id = 13;
$subPublishers = Mage::getModel('catalog/category')->load($publisher_cat_id)->getChildren();

$publisher_names = array();
foreach(explode(",",$subPublishers) as $item)
    $_cat = Mage::getModel('catalog/category')->setStoreId(Mage::app()->getStore()->getId())->load($item);
    array_push($publisher_names,$_cat->getName() . "," . $_cat->getUrl());

Anyone had this issue? Please let me know if you know how to fix this.

2 Answers 2



  • function only give active categories
  • It is provide only sub categories not sub subcategories.

If you want to get all sub categories then use :getChildrenCategoriesWithInactive();

Also want to all child level categories then try below code:

$subPublishers=Mage::getResourceModel('catalog/category_collection')->addAttributeToFilter('path', array(
    array('like' => '%'.$publisher_cat_id.'%'), //spaces on each side
    array('like' => '%'.$publisher_cat_id), //space before and ends with $needle
    array('like' => $publisher_cat_id.'%') // starts with needle and space after
  • Well i need the second code to work because getChildrenCategoriesWithInactive(); gives me those categories that has level 3. I did't mentioned that i have imported those categories with magmi. So i have alot of categories that has level 0 there. The second code gives me all of categories from publisher category and alot not from the publisher category.
    – 90sKid
    Apr 14, 2016 at 10:56
  • Managed to fix it by using your code and modifying publisher category id it like this: $publisher_cat_id = "1/3/13/"; Thank you!!
    – 90sKid
    Apr 14, 2016 at 11:05

You can try following code:


        $category = Mage::getModel('catalog/category')->load(2);
        $subCategory=($category->getResource()->getChildren($category, true));
        foreach ($subCategory as $categoryID)
                $sCategory = Mage::getModel('catalog/category')->load($categoryID);
                $catnames = array();
                foreach ($sCategory->getParentCategories() as $parent) {
                    $catnames[] = $parent->getName();
                    /* Do Something here */
                echo  implode('>>',$catnames);
                echo '<br>';


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.