显示与类别,子类别和产品菜单 - Magento的
问题描述:
我一直在寻找实现菜单系统像following显示与类别,子类别和产品菜单 - Magento的
我有1类,汽车,有2子类,新的和二手
我想在下拉列表中显示主类别,然后是新建,将所有产品列为列表,然后使用,将所有产品列入列表。
我已经尝试使用提供的链接中的代码,但它似乎包括翻转选项,扩大了菜单,并且产品未在类别下方列出。
感谢
答
<?php $_helper = Mage::helper('catalog/category') ?>
<?php $_categories = $_helper->getStoreCategories() ?>
<?php $currentCategory = Mage::registry('current_category') ?>
<?php if (count($_categories) > 0): ?>
<ul>
<?php foreach($_categories as $_category): ?>
<li>
<a href="<?php echo $_helper->getCategoryUrl($_category) ?>">
<?php echo $_category->getName() ?>
</a>
<?php $_category = Mage::getModel('catalog/category')->load($_category->getId()) ?>
<?php $_subcategories = $_category->getChildrenCategories() ?>
<?php if (count($_subcategories) > 0): ?>
<ul>
<?php foreach($_subcategories as $_subcategory): ?>
<li>
<a href="<?php echo $_helper->getCategoryUrl($_subcategory) ?>">
<?php echo $_subcategory->getName() ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
来源:http://fishpig.co.uk/magento-tutorials/display-categories-and-subcategories-in-magento