April 26, 2012 by admin
Magento: Getting the current category
I have often found the need to be able to display the name or other details about the category I am currently in. A product can obviously be included in more than one category, so figuring out which category you are currently inside would be useful. In the core catalog code in Magento, everytime you visit a category page a method is fired, setCurrentCategory(). This sets an entry in the magento registry with the current category object attached.
Here is the code snippet to get the current category in magento
<?php $currentCategory = Mage::registry('current_category'); ?>