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();

No comments:

Post a Comment