我在过去创建我的主题叫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块下拉列表中选择类别块。
heyy乔恩,非常感谢你!虽然它不是我正在寻找的,但它绝对帮助我解决我的问题!谢谢:) – Sushil 2012-02-20 05:05:30
啊,是的,我错过了一点,说你想从儿童类别中检索产品。很高兴它无论如何都有帮助。 – 2012-02-21 12:03:48