Magento get current category

19.Oct.2010

If you are using a Magento and you want to know what is the current category in order to show it to your user, you can do it by using following snippet.

1
2
3
4
5
6
//if there is no current category return
if(!Mage::registry('current_category')) return;
 
//if current category is defined
$magentoCurrentCategory = Mage::registry('current_category');
echo 'Your current category in Magento is:' . $magentoCurrentCategory->getName();