I want current category name on product view Page.

How to get current category name on product view Page?


1 Answer 1


A product can be attached with multiple category so directly not able to get current category of that product but if you visit category page and then goes to product page at that time category is in session so you can get category by

echo  $_category_detail->getName(); 

if you are directly landing on a product page without accessing any category then there is no category in session so at that time you can get category of that product by

$categoryIds = $_product->getCategoryIds();

    if(count($categoryIds) ){
        $firstCategoryId = $categoryIds[0];
        $_category = Mage::getModel('catalog/category')->load($firstCategoryId);

        echo $_category->getName();
  • In this i get first level current category but i want lower level category as current category.
    – Deep Shah
    Commented Feb 14, 2020 at 6:47
  • You can reverse the category array. array_reverse( $_product->getCategoryIds() ); Commented Feb 14, 2020 at 7:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.