Get the Parent Categories Using Current Category Id in Magento

<?php
    //get current category
    $category = Mage::getModel('catalog/layer')->getCurrentCategory();
    $cat_id = $category->getId();
    //load category
    $category = Mage::getModel('catalog/category')->load($cat_id);
    $catnames = array();
    foreach ($category->getParentCategories() as $parent) {
	$catnames[] = $parent->getId();
    }
?>

Leave a Reply

Your email address will not be published. Required fields are marked *