Search This Blog

Tuesday, July 5, 2011

magento get parent category of or from current category

You can get current category from the following code:
$currentCategory = Mage::registry('current_category');

You can get the parent category from the following code:

/**
* You want the parent category of a sub-category
* Let the sub-category be $subCategory
*/

$parentCategory = Mage::getModel('catalog/category')->load($subCategory->getParentId());

No comments:

Post a Comment