如何获得按位置排序的Magento类别数组?

时间:2012-06-14 05:10:50

标签: magento

        <?php $currentCat = Mage::registry('current_category');
            if ( $currentCat->getParentId() == Mage::app()->getStore()->getRootCategoryId() )
            {
                $loadCategory = $currentCat;
            }
            else
            {
                $loadCategory = Mage::getModel('catalog/category')->load($currentCat->getParentId());
            }    
            $subCategories = explode(',', $loadCategory->getChildren());

            foreach ( $subCategories as $subCategoryId )
            {
                $cat = Mage::getModel('catalog/category')->load($subCategoryId);

                if($cat->getIsActive())
                {
                    if ($currentCat->getEntityId() == $subCategoryId)
                    {
                        echo '<b>'.$cat->getName().'</b><br />';
                    }
                    else
                    {
                        echo '<a href="'.$cat->getURL().'">'.$cat->getName().'</a> ('.$cat->getProductCount().')<br />';
                    }
                }
            }
        ?>

0 个答案:

没有答案