2012-02-16 65 views
0

我有一个类似音乐的产品,它在我的magento网站上没有任何产品。所以这就是我的分类结构。Magento:分类页面

音乐(0)

--- | _流派(0)

------ | _POP(3)

------ | _R &乙(4)

--- | _Artists(0)

------ | _Rihanna(4)

--- | _Critics选项(9)

所以现在有什么办法可以检索所有的儿童类别产品,当我在音乐或流派?!?

任何帮助,将不胜感激

感谢

回答

0

我在过去创建我的主题叫subcategorylist.phtml模板/目录/产品中的模板做到了这一点/

<ul class="list"> 
    <?php 
    $currentCat = Mage::registry('current_category'); 

    $subCats = $currentCat->getChildren(); 


    foreach(explode(',',$subCats) as $subCatid) 
    { 
      $_category = Mage::getModel('catalog/category')->load($subCatid); 
      if($_category->getIsActive()) 
      { 
        $catUrl = $_category->getURL(); 
        $catName = $_category->getName(); 

        if($_category->getImageUrl()) 
        { 
          $catimg = $_category->getImageUrl(); 
        } 

        echo '<li><a href="'.$catUrl.'" title="View the products for this category"><img src="'.$catimg.'" alt="'.$catName.'" /></a>'; 
        echo '<h2><a href="'.$catUrl.'" title="View the products for this category">'.$catName.'</a></h2></li>'; 

      } 
    } 

    ?> 
    </ul> 

然后在CMS中的magento后端 - >静态块中添加一个名为Categories的新块,其代码如下

{{block type="catalog/product" template="catalog/product/subcategorylist.phtml"}} 

然后,您可以转到您希望实施的特定类别,然后选择显示设置并从CMS块下拉列表中选择类别块。

+0

heyy乔恩,非常感谢你!虽然它不是我正在寻找的,但它绝对帮助我解决我的问题!谢谢:) – Sushil 2012-02-20 05:05:30

+0

啊,是的,我错过了一点,说你想从儿童类别中检索产品。很高兴它无论如何都有帮助。 – 2012-02-21 12:03:48