0

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

9
  • Have you tried getChildrenCategories()? getChildren() should return a string with coma seperated ids, not an array at all. Commented Apr 22, 2015 at 8:09
  • the source code of 1.9.1.0 says that getChildren() returns array but indeed official document from magento says it is string.... anyway it is empty and getChildrenCategories() also returns empty array....
    – bogumbiker
    Commented Apr 22, 2015 at 8:56
  • should I be looking at catalog_category_entity table...?
    – bogumbiker
    Commented Apr 22, 2015 at 9:04
  • Well, at this point I would try and output the $category->getData() via print_r or var_dump and see what's in there for children Commented Apr 22, 2015 at 9:21
  • @user3154108 I am getting following after print_r($category->getData()): Array ( [entity_id] => 30 [entity_type_id] => 3 [attribute_set_id] => 3 [parent_id] => 2 ........ )
    – bogumbiker
    Commented Apr 24, 2015 at 1:57

1 Answer 1

0

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!

0

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.