Magento: Get category name

来源:互联网 发布:wish for mac 编辑:程序博客网 时间:2024/05/21 21:45

$product->getCategoryIds() givesarray of category ids which the product is associated to. We canloop through this array and load each category to get the categoryname and url.

<?php$categoryIds = $product->getCategoryIds();foreach($categoryIds as $categoryId) {    $category = Mage::getModel('catalog/category')->load($categoryId);    ?>            Category: <a href="<?php echo $category->getCategoryUrl() ?>"><?php echo $category->getName() ?></a><br/> <?php}?>
原创粉丝点击