drpp5680 2013-07-03 16:10 采纳率: 0%
浏览 36
已采纳

在产品详细信息页面上显示此产品的相同选定子类别的产品列表

I am struggling from last two days to display product list (only product name with link) at product detail page which have same subcategory as detailed product has. In detail, I have two level category:Please take a look at image:

enter image description here

Now suppose when user goes to prodcut "Zest" item detail page then he can only see "Zest" and "Exotic" items into my list. Not the other items from subcategory (e.g. Indonesian... Blue border color). Here I aam able to get category id of "PODS" (its main category) but cannot get id of "House Blend(2)" subcategory.

Can anyone please help to get these product list? Thanks in advance.

  • 写回答

1条回答 默认 最新

  • douxing5199 2013-07-03 17:25
    关注

    To get all subcategories of a category:

    $children = Mage::getModel('catalog/category')->getCategories(50);
    $searchInCategories = '';
    foreach ($children as $category) {
    
        //Add , after every id
        if (strlen($searchInCategories) > 0)
            $searchInCategories .= ',';
    
        $searchInCategories .= $category->getId();
    }
    

    Where 50 is a category id, in your case this would be PODS id.

    Now you need to alter the search query for your products:

    ->addAttributeToFilter('category_id', array('in' => array('finset' => $searchInCategories)))
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题