Filter child categories by id
-
12-12-2019 - |
Question
I would like to exclude a number of child categories from my catalogue collection in order to amend a mega menu I am creating.
I have tried the following:
$subAcc = $acc->getChildrenCategories();
$subAcc->addAttributeToFilter('category_id', array('nin' => array(321, 322)));
But this errors. What is the correct way to do this?
Solution
Just change category_id
to entity_id
and code:
$subAcc = $acc->getChildrenCategories();
$subAcc->addAttributeToFilter('entity_id', array('nin' => array(321, 322)));
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange