I need to exclude a single category from a collection of categories. The code I use to get the collection:
$layer = Mage::getSingleton('catalog/layer');
$_category = $layer->getCurrentCategory();
$_parent_category = $_category->parent_category;
$_grandparent_cat = $_parent_category->getParentCategory();
$eid = $_parent_category->entity_id;
and now the code I use to filter the categories
$_new_categories = $_grandparent_cat
->getChildrenCategories()
->addAttributeToSelect("*")
->addAttributeToFilter('entity_id', array('neq'=>$eid));
This should take all child categories of the grandpared_cat and return them, excluding the current cat(the one
with $eid) but it returns all subcategories.
How can I solve this? Thanks :)!
Best Answer
Mage_Catalog_Model_Resource_Category::getChildrenCategories
returns a loaded collection, so your filter does not get applied.I'm not sure the best way to proceed as
_getChildrenCategoriesBase
is a protected method. This might be the type of collection you could create if it was not a protected method