Showing posts with label Magento get category name from product id. Show all posts
Showing posts with label Magento get category name from product id. Show all posts

Monday, 8 December 2014

Get category name by product id magento


Get category name by product id magento

$product = Mage::getModel('catalog/product')->load($_product->getId());
$cats = $product->getCategoryIds();
foreach($cats as $categoryId) {
    $category = Mage::getModel('catalog/category')->load($categoryId);
    echo $category->getName();
}