$intRootCategoryId = Mage::app()->getStore()->getRootCategoryId();
$objParentCategories = Mage::getModel('catalog/category')->getCollection()->addAttributeToFilter('parent_id',$intRootCategoryId)->addAttributeToFilter('is_active',1)->setOrder('position','ASC');
foreach($objParentCategories as $objSpecParentCategory)
{
$objFinalCategory = Mage::getModel('catalog/category')->load($objSpecParentCategory->getId());
$objSubCategories = Mage::getModel('catalog/category')->getCollection()->addAttributeToFilter('parent_id',$objSpecParentCategory->getId())->addAttributeToFilter('is_active',1)->setOrder('position','ASC');
if ($objSubCategories->count())
{
foreach($objSubCategories as $objSpecSubCategory)
{
$objFinalSubCategory = Mage::getModel('catalog/category')->load($objSpecSubCategory->getId());
$objFinalSubCategory->getUrl();
$objFinalSubCategory->getName();
}
}
}
No comments:
Post a Comment