6/21/2010

How to Get Current Category in Magento

There are Many way to get Current category in magento
I am showing here two way
If you wish to check the current category in everypage(including Homepage as default category is 2) then you can write these code $_cat = new Mage_Catalog_Block_Navigation();
$curent_cat = $_cat->getCurrentCategory();
$curent_cat_id = $curent_cat->getId();

$category = Mage::registry('current_category')->getName();

By the Help of registry()function of magento we can get the Current category ,For get name of that category we can use getName() function .If you need the Id then write getId() instead of getName();

No comments:

Post a Comment