Just another WordPress.com weblog

$layer = Mage::getSingleton(‘catalog/layer’);
$_category = $layer->getCurrentCategory();
$currentCategoryId= $_category->getId();

vishal surani


Comments on: "Magento : Get Current Category – Category Id" (9)

  1. A better way to get the current category is to use:

    $_category = Mage::registry(‘current_category’);


  2. That’s good tip, I appreciate your hard work. Please keep it up.


  3. […] Magento : Get Current Category – Category Id June 20101 comment 5 […]

  4. Very Good Article.


  5. thanks ..

  6. Really worked.Thank you very much!!!

  7. You could use Mage::getModel(‘catalog/layer’)->getCurrentCategory() also

  8. thnks .. very good article. it helps me most… thnks again..

  9. Thanks Vishal, Your way to get the cat id is the only one that worked for me in the head.phtml file for Magento 1.7. It is a little frustrating to have such a hard time getting something like this to work in your template.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: