根据管理员在 Magento 中的位置对类别进行排序 [英] Sorting categories in Magento according to the position in admin

查看:23
本文介绍了根据管理员在 Magento 中的位置对类别进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何对这个类别列表进行排序(我在这里学习了本教程http://www.devinrolsen.com/magento-custom-category-listing-block/) 在 magento 中按在管理面板中的位置?目前按id排序

I would like to know how to sort this list of categories (I followed this tutorial here http://www.devinrolsen.com/magento-custom-category-listing-block/) in magento by position in the admin panel? Currently it is sorted by id

<?php
$cats = Mage::getModel('catalog/category')->load(3)->getChildren();
$catIds = explode(',',$cats);
?>
<ul>
<?php foreach($catIds as $catId): ?>
    <li>
        <?php
            $category = Mage::getModel('catalog/category')->load($catId);
            echo '<a href="' . $category->getUrl() . '">';
            echo $category->getName() . '</a>';
        ?>
    </li>
<?php endforeach; ?>
</ul>

推荐答案

您在处理 ID 和其他东西时为自己做了太多工作.以下已按位置排序为标准.

You're making way too much work for yourself trying to deal with IDs and stuff. The following is already sorted by position as standard.

<?php
$cats = Mage::getModel('catalog/category')->load(3)->getChildrenCategories();
?>
<ul>
<?php foreach($cats as $category): ?>
    <li>
        <a href="<?php echo $category->getUrl() ?>"><?php echo $category->getName() ?></a>
    </li>
<?php endforeach; ?>
</ul>

这篇关于根据管理员在 Magento 中的位置对类别进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆