Sorting categories in Magento according to the position in admin

后端 未结 5 637
天命终不由人
天命终不由人 2020-12-31 12:27

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 posi

5条回答
  •  旧巷少年郎
    2020-12-31 12:45

    If you want to sort the categories by the position created in adminhtml you can then, since catalog/category is an instance of Mage_Catalog_Model_Resource_Category_Collection, make a query where you specify what you want to select, filter and/or sort.

    The case here is getting categories from catalog_category_entity select only the name, filtering after the id and sort the query on the position.

    getCollection()
    ->addAttributeToSelect('name')
    ->addFieldToFilter('parent_id', $categoryId)
    ->addAttributeToSort('position', ASC);
    ?>
    

提交回复
热议问题