根据管理员位置对Magento中的类别进行排序 [英] Sorting categories in Magento according to the position in admin
本文介绍了根据管理员位置对Magento中的类别进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道如何对这个类别列表进行排序(我在这里按照本教程进行操作
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屋!
查看全文