【问题标题】:Magento Sort Categories AlphabeticallyMagento 按字母顺序对类别进行排序
【发布时间】:2015-10-27 19:08:22
【问题描述】:

最近我被要求在左侧导航中按字母顺序显示顶级类别及其子类别。

我使用的代码是

<ul id="demo1" class="nav">
<?php $helper = Mage::helper('catalog/category') ?>
<?php $categories = $helper->getStoreCategories(); ?>
<?php foreach ($categories as $_category): ?>
<?php echo $this->drawItem($_category) ?>
<?php endforeach ?>
</ul>

不幸的是,它显示类别但不按字母顺序显示。

也是因为我使用了类别辅助功能而没有显示吗?

是否有任何内置功能可以按字母顺序显示类别及其子类别?

谢谢

【问题讨论】:

    标签: magento categories


    【解决方案1】:

    删除:

    <?php $categories = $helper->getStoreCategories(); ?>
    

    添加:

    // sorted by name, fetched as collection
    $categories = $helper->getStoreCategories('name', true, false);
    
    // sorted by name, fetched as array
    $categories = $helper->getStoreCategories('name', false, false);
    

    希望能有所帮助!

    【讨论】:

      猜你喜欢
      • 2011-08-29
      • 1970-01-01
      • 1970-01-01
      • 2013-12-30
      • 2017-05-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多