在Magento的每个产品详细信息页面上,我想列出属于哪个类别。
我该如何去实现这个目标呢?
发布于 2010-08-19 19:20:25
试一试:
$currentCatIds = $_product->getCategoryIds();而且还
$categoryCollection = Mage::getResourceModel('catalog/category_collection')
->addAttributeToSelect('name')
->addAttributeToSelect('url')
->addAttributeToFilter('entity_id', $currentCatIds)
->addIsActiveFilter();干杯,JD
发布于 2012-03-15 21:16:17
您可以使用以下代码在产品详情页中显示与所选产品相关的所有类别。
<?php $categories = $_product->getCategoryIds(); ?>
<?php foreach($categories as $k => $_category_id): ?>
<?php $_category = Mage::getModel('catalog/category')->load($_category_id) ?>
<a href="<?php echo $_category->getUrl() ?>"><?php echo $_category->getName() ?></a>
<?php endforeach; ?>发布于 2017-04-21 21:32:19
该代码将根据店铺id获取产品类别名称。这也将使用完整的多商店和多网站的概念
$product = Mage::getModel('catalog/product')->load($product_id);
$cats = $product->getCategoryIds();
foreach ($cats as $category_id) {
$_cat = Mage::getModel('catalog/category')->setStoreId(Mage::app()- >getStore()->getId())->load($category_id);
echo $_cat->getName();
}https://stackoverflow.com/questions/3521021
复制相似问题