getChildrenCategories在magento中不起作用,请在admin中按职位对类别进行排序
我不会像在管理中那样在前端对类别进行排序,如果我使用getChildren,那么它不会像在管理中那样对类别进行排序,但是如果我使用getChildrenCategories,那么不会有结果getChildrenCategories在magento中不起作用,请在admin中按职位对类别进行排序,magento,Magento,我不会像在管理中那样在前端对类别进行排序,如果我使用getChildren,那么它不会像在管理中那样对类别进行排序,但是如果我使用getChildrenCategories,那么不会有结果 <?php $cats = Mage::getModel('catalog/category')->load(74)->getChildren(); $catIds = explode(',',$cats); $categories = array(); foreach($catI
<?php
$cats = Mage::getModel('catalog/category')->load(74)->getChildren();
$catIds = explode(',',$cats);
$categories = array();
foreach($catIds as $catId) {
$category = Mage::getModel('catalog/category')->load($catId);
$categories[$category->getName()] = array(
'url' => $category->getUrl(),
'img' => $category->getImageUrl()
);
}
ksort($categories, SORT_STRING);
?>
<ul>
<?php foreach($categories as $name => $data): ?>
<li>
<a href="<?php echo $data['url']; ?>" title="<?php echo $name; ?>">
<img class="cat-image" src="<?php echo $data['img']; ?>" />
</a>
</li>
<?php endforeach; ?>
</ul>
-
使用有序的集合。请参见以下示例:
<?php
$category = Mage::getModel('catalog/category')->load(74);
$collection = $category->getCollection();
->addAttributeToSelect('name')
->addAttributeToSelect('image')
->addIdFilter($category->getChildren())
->setOrder('name', Varien_Db_Select::SQL_DESC);