Hi.. Guys today i have learned something very interesting, which is HOW TO GET (ONLY) PARENT CATEGORIES from the category tree.
[php]
$categories = Mage::getModel('catalog/category')->getCollection()
->addAttributeToSelect('*')//or you can just add some attributes
->addAttributeToFilter('level', 2)//2 is actually the first level
->addAttributeToFilter('is_active', 1);//if you want only active categories
foreach ($categories as $_category){
echo $_category->getName().'<>';
}
[/php]
Hope it helps someone!!
Happy coding :-)
No comments:
Post a Comment