douxunwei7083 2014-01-08 09:12
浏览 18

在产品页面上显示属于类别

I try to show what categories the product is included in the product page with a fillter so I only show the product in a certain category or its subcategories.

I have a category (id 10) I put all the campaigns in subcategories At the product level, I would then see if the product is in category 10 or its sub-categories with a clickable link to the category.

Here's is what i got so far. This code bellow gives med all categories that the product is in

<?php
    $currentCatIds = $_product->getCategoryIds();
    $categoryCollection = Mage::getResourceModel('catalog/category_collection')
    ->addAttributeToSelect('name')
    ->addAttributeToSelect('url')
    ->addFieldToFilter('level', array('eq' => 4))
    ->addAttributeToFilter('entity_id', $currentCatIds)
    ->addIsActiveFilter();
?>

And here is my output

<?php foreach($categoryCollection as $cat):?>
    <a href="<?php echo $cat->getUrl(); ?>" title="<?php echo $cat->getName();  ?>"><?php echo $cat->getName();?></a></br>
<?php endforeach; ?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
    • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
    • ¥15 cmd cl 0x000007b
    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
    • ¥500 火焰左右视图、视差(基于双目相机)
    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号