$product->getCategoryIds()<wbr></wbr>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/>
<wbr><?php
}
?>
</wbr>
本文介绍如何使用Magento框架的$product->getCategoryIds()方法获取产品关联的类别ID,并通过循环加载每个类别以获取类别名称和URL。
180

被折叠的 条评论
为什么被折叠?



