Google+

Pages

Monday, July 30, 2012

Get The Current Category in Magento


Try below code to get currently loaded product id:

$category_id = Mage::getSingleton('catalog/layer')
               ->getCurrentCategory()
               ->getId();

When you don’t have access to $this, you can use Magento registry:

$category_id Mage::registry('current_category')->getId();

Enjoy.. :)

No comments: