【发布时间】:2016-01-07 15:59:31
【问题描述】:
我在我的 Magento CMS 主页中使用以下块:
{{block type="catalog/product_list" name="catalog_list" category_id="1420" template="catalog/product/listStart.phtml"}}
如何才能获得块中指定的 category_id 的所有子类别的输出(在本例中为 id 1420)。
到目前为止,我有以下代码:
<?php
$_category = $this->getCurrentCategory();
$collection = Mage::getModel('catalog/category')->getCategories($_category->entity_id);
$helper = Mage::helper('catalog/category');
?>
<div class="category-products">
<div id="carousel">
<ul class="products-in-row">
<?php $i=0; foreach ($collection as $cat): ?>
<li class="item">
<?php echo $cat->getName();?>
</li>
<?php endforeach ?>
</ul>
</div>
我只获取主类别的所有子类别。
【问题讨论】:
-
@DouglasRadburn - 不同的问题。据我所知,这个问题中的这个问题无法将值
1420从category_id应用到集合中,而不是一般如何去做。这也是与您链接的问题不同的情况。
标签: php magento categories