Saturday 30 January 2016

How to display category name by product id in Magento

If you want to get Category Name by Product Id in Magento. Use following code:



<?php 

$product = Mage::getModel('catalog/product')->load($_product->getId());


$cat_id = $product->getCategoryIds();


foreach($cat_id as $categorycbId) {


$category_id = Mage::getModel('catalog/category')->load($categorycbId);


echo $category_id->getName();


}

?>


6 comments:

  1. Its really glad to know about how to display category name by product id in magento. Thanks for posting these kind of posts, keep updating.
    gemstone store in lajpat nagar


    ReplyDelete
  2. Its really very informative post about display category name. Glad to know about it, very innovative post, keep posting.
    Color Coated Profile Sheets In Haryana : VIMP

    ReplyDelete
  3. Very informative post and pretty well maintained, this post is very important for the Magento Developer. Thanks for posting and keep updating your post.
    vitamin c gel face wash

    ReplyDelete
  4. Its a really nice post, thanks for it and keep updating.
    omega 3 fatty acids capsules

    ReplyDelete