1

In my module, I am getting the current ID and then using the category repository and the "getChildren" method. This works great, except it doesn't return child categories with product counts of 0.

How would I get around this?

"getAllChildren" seemed promising, but returned all descendants, whereas I'm just looking for the immediate children, regardless of product counts.

Edit: For testing purposes, I've added products to these categories that aren't showing up. Their ID's still aren't being returned via the GetChildren method.

  • 1
    Categories are full of strange limitations. I have a different but similar challenge and ended up using getAllChildren and adding a condition later to filter out the crap (for example it returns that parent itself as first element) – iphigenie Oct 7 at 8:55
0

Have you tried getChildrenCategories() instead? If in doubt var_dump($catergory->getIsActive()). Although I've generally encountered the other way. I've had to do work to hide empty categories.

https://magento.stackexchange.com/a/80/70343

  • getChildrenCategories() returns the same categories, unfortunately – brackfost May 21 at 13:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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