How to get parent category Id in Magento

To get Parent Category Id you must know the current category Id, for that you need to write
<?php 
$_cat = new Mage_Catalog_Block_Navigation();
$curent_cat = $_cat->getCurrentCategory();
$curent_cat_id = $curent_cat->getId();?>

Now you can get Parent Category Id.
write the code given below to get the Id
<?php $parentId=Mage::getModel('catalog/category')->load($curent_cat_id)->getParentId();
echo $parentId; // $parentId will print your current category's parent Id
?>

Source:http://xhtmlandcsshelp.blogspot.in/2010/08/how-to-get-parent-category-id-in.html

1 comments:

Wow, seriously well formulated and well written about Magento Integration.

July 2, 2014 at 8:31 AM comment-delete

Post a Comment