在magento中仅显示搜索表单中的父类别名称。
当前类别显示:
Test1:
TestA
TestB
Test2:
Testc
Testd
预期结果:
Test1
Test2
在app \ design \ frontend \ default \ themename \ template \ catalogsearch \ form.mini.phtml
答案 0 :(得分:1)
要显示顶级类别,请尝试以下代码
<?php $_helper = Mage::helper('catalog/category') ?>
<?php $_categories = $_helper->getStoreCategories() ?>
<?php if (count($_categories) > 0): ?>
<ul>
<?php foreach($_categories as $_category): ?>
<li>
<a href="<?php echo $_helper->getCategoryUrl($_category) ?>">
<?php echo $_category->getName() ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>