I want to know how I can get all active and inactive category children's

This code get me only the active childrens.

$parentCategory = Mage::getModel('catalog/category')->load($id);        
$childCategory = Mage::getModel('catalog/category')->getCollection()        
    ->addAttributeToFilter('name', $categoryName)
    ->getFirstItem()    // Assuming your category names are unique ??


3 Answers 3


Hello Check below code may be help you

$collection = Mage::getResourceModel('catalog/category_collection')
   ->addAttributeToFilter('is_active', array('in' => array(0,1)))
  ->addAttributeToFilter('parent_id', $id);

echo count($collection);
  • This works but the is_active filter is useless. is active can only be 0 or 1.
    – Marius
    Commented Nov 14, 2014 at 7:49

I know it's a bit late but I just came across this function, getChildrenCategoriesWithInactive, so now I do:

$_category = Mage::getModel('catalog/category')->loadByAttribute('name', 'mycategoryname');
$_subcategories = Mage::getModel('catalog/category')->load($_category->getId())->getChildrenCategoriesWithInactive();
     foreach ($_subcategories as $_subcategory):



This what I did

$query = "SELECT cce.entity_id FROM catalog_category_entity as cce left join "
        . "catalog_category_entity_varchar as ccev on cce.entity_id = ccev.entity_id "
        . "where cce.parent_id = :parent_id "
        . "and ccev.attribute_id = 41 and ccev.value = :ccev_value";
$values = array('parent_id' => $id,
                'ccev_value' => $categoryName,                 

$result = $readConnection->fetchAll($query,$values);  
if (count($result) > 0){
    return $result[0]['entity_id'];
    return '';

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.