Magento 1.9 Category Issue – $category->getChildren() Not Working

categorycategory-treemagento-1.9

When I am using $category->getChildren(); and I am getting empty array? I have children categories defined and I can see them via Admin Panel.
Where should I look for the clue?
thanks

Best Answer

ok found the solution.

my $category is of Varien_Data_Tree_Node type and
$category->getChildren() is Varien_Data_Tree_Node_Collection the problem was that in the Magento Config, Maximal Depth was set to 1. That is why I was getting empty collection (Varien_Data_Tree_Node_Collection) for each category and children_count was OK. Changing Maximal Depth variable to 2 solved the problem.

Thanks!

Related Topic