我有一个像音乐这样的类别,在我的magento网站上没有任何产品。这就是我的分类结构。
音乐(0)
-|_ genre (0)
-|_POP(3)
-|_R&B(4)
-|_Artists(0)
-|_Rihanna(4)
-|_评论家的选择(9)
那么现在有没有方法可以检索所有的儿童类别产品,当我在音乐或流派?!?
任何帮助都将不胜感激
谢谢
发布于 2012-02-17 06:46:00
我以前已经在我的主题中创建了一个名为subcategorylist.phtml的模板,它位于template/catalog/product/
<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>
然后,在magento后端的CMS ->静态块中,使用以下代码添加一个名为Categories的新块
{{block type="catalog/product" template="catalog/product/subcategorylist.phtml"}}
然后,您可以转到您希望在go上实现的特定类别,显示设置,并从CMS块下拉菜单中选择Categories块。
https://stackoverflow.com/questions/9309600
复制相似问题