Magento category order on frontend
I want to change t开发者_如何学Che default order of categories in Magento frontend navigation to order by name. Running Magento 1.5.
Does anyone have a clue?
You can manually order the categories in admin by dragging them up and down in the left pane of "Manage Categories" page.
We have been searching on a way to do this also, and ended up doing this:
<?php
...
$categories = array(1,3,5); // this holds the category ids you want to show, in the correct order
foreach($categories as $cat){
Mage::getModel("catazlog/category")->load($cat);
// Do whatever you want here
}
?>
It definitely isn't the cleanest way to achieve what you are trying to do, but just offering you a quick (dirty?) solution.
-Kenny
You would need to build the collection first, then sort the attribute
Mage::getModel('catalog/category')->getCollection()->addFieldToFilter('parent_id', '319')->addAttributeToSort('name', 'ASC');
In Admin Panel go to Catalog—>Manage Categories. From there you can change categories order by just drag-and-dropping categories right in category tree at the left-hand side of the page. Good luck!!!
精彩评论