Archive
Get Category Name From Category Id Magento
$mainCategory = Mage::getModel(‘catalog/category’)->load($categoryId);
$mainCategoryName = $mainCategory->getName();
Product collection with limit Magento
$productCollection = Mage::getResourceModel(‘catalog/product_collection’)
->addCategoryFilter($_category)
->addAttributeToSelect(‘*’)
->setPageSize(5);
$productCollection->load();
Magento subcategories list filtered by category name
$collection = Mage::getModel(‘catalog/category’)->getCollection()
->addFieldToFilter(‘name’,array(‘like’ => ‘%New Arrivals%’))
->addFieldToFilter(‘parent_id’, array(‘eq’=>$categoryId ))
->load();
foreach ($collection as $category):
echo $category->getName();
endforeach;
Get child categories Magento
<?php
$_category = Mage::getModel(‘catalog/category’)->load(17); //$categoryid for which the child categories to be found
$childCategories = $category_model->getResource()->getAllChildren($_category); //array consisting of all child categories id
print_r($childCategories);
?>