Php Magento:以与管理后端树结构相同的顺序显示子类别

Php Magento:以与管理后端树结构相同的顺序显示子类别,php,zend-framework,magento,magento-1.7,magento-1.6,Php,Zend Framework,Magento,Magento 1.7,Magento 1.6,我正在使用Magento 1.7.2,显示当前类别的子类别和子类别列表。我的问题是,子类别与管理后端树结构中的顺序不同。看起来它们是通过id订购的,从较小的id号到最高的id号。我需要他们显示,因为他们是在管理后端订购。这是我目前的代码: <?php $currCat = Mage::registry('current_category'); $parentname = $currCat->getName(); $collection = Mage::getModel('catal

我正在使用Magento 1.7.2,显示当前类别的子类别和子类别列表。我的问题是,子类别与管理后端树结构中的顺序不同。看起来它们是通过id订购的,从较小的id号到最高的id号。我需要他们显示,因为他们是在管理后端订购。这是我目前的代码:

<?php 
$currCat = Mage::registry('current_category');
$parentname = $currCat->getName();
$collection = Mage::getModel('catalog/category')->getCategories($currCat->getEntityId());
$subcats = $currCat->getChildren();

$_helper = $this->helper('catalog/output');
echo '<h2 class="titleCat"><strong>'.$parentname.'</strong></h2>';
?>

<?php 
$currCat = Mage::registry('current_category');
$parentname = $currCat->getName();
$collection = Mage::getModel('catalog/category')->getCategories($currCat->getEntityId());
$subcats = $currCat->getChildren();

$_helper = $this->helper('catalog/output');
echo '<h2 class="titleCat"><strong>'.$parentname.'</strong></h2>';
?>

<!-- We list sub sub categories -->
<div class="colLeftNav">
<ul class="colLeftSubCats">
<?php
foreach(explode(',',$subcats) as $subCatid)
{
$_category = Mage::getModel('catalog/category')->load($subCatid);
if($_category->getIsActive()) {
$sub_cat = Mage::getModel('catalog/category')->load($_category->getId());
$sub_subcats = $sub_cat->getChildren();
echo '<div class="subMainCat"><a href="'.$_category->getURL().'" title="Show products "'.$_category->getName().'" category">'.$_category->getName().'</a></div>';
foreach(explode(',',$sub_subcats) as $sub_subCatid)
{
$_sub_category = Mage::getModel('catalog/category')->load($sub_subCatid);
if($_sub_category->getIsActive()) {
echo '<li class="subCat"><a href="'.$_sub_category->getURL().'" title="show products "'.$_sub_category->getName().'" category">'.$_sub_category->getName().'</a></li>';
}
}
}
}
?>
</ul>
</div>

我几乎被困在这里,不知道如何解决这个问题。任何帮助都将不胜感激

像这样的

$cat_id = 10;
$category = Mage::getModel('catalog/category')->load($cat_id);
$collection = Mage::getModel('catalog/category')->getCategories($cat_id, 0, true, true);

foreach ($collection as $cat) {
    echo $cat->getId().' '.$cat->getPosition().' '.$cat->getName().'<br/>';
}
$cat_id=10;
$category=Mage::getModel('catalog/category')->load($cat_id);
$collection=Mage::getModel('catalog/category')->getCategories($cat_id,0,true,true);
foreach($cat作为$collection){
echo$cat->getId()。'.$cat->getPosition()。'.$cat->getName()。
; }
getCategories中的额外参数是什么?*param int$parent*param int$recursionLevel*param bool$sorted*param bool$asCollection*param bool$toload这是非常有用的。