nerijus
8/30/2015 - 4:38 PM

Get category child by name

Get category child by name

// CATEGORY
$cat = Mage::getResourceModel('catalog/category_collection')->addFieldToFilter('name', 'Category_Name_Here');
$cat->getFirstItem()->getEntityId();

// SUBCATEGORY
$category = Mage::getResourceModel('catalog/category_collection')
    ->addFieldToFilter('name', 'Men')
    ->getFirstItem() // The parent category
        ->getChildrenCategories()
        ->addFieldToFilter('name', 'Clothing')
        ->getFirstItem(); // The child category

$categoryId = $category->getId();