how to get all product collection order by product

2020-06-16 03:21发布

I want to get the product collection order by product name in magento? any idea??

标签: php magento
2条回答
甜甜的少女心
2楼-- · 2020-06-16 03:40

This should help:

$collection = Mage::getModel('catalog/category')->load($categoryId)
->getProductCollection()
->addAttributeToSort('name', 'ASC');

see in Magento Wiki

查看更多
何必那么认真
3楼-- · 2020-06-16 03:45

Get all products sorted by product name ascending:-

$collection = Mage::getModel('catalog/product')
                         ->getCollection()
                         ->addAttributeToSort('name', 'ASC');

Get all products sorted by product name descending:-

$collection = Mage::getModel('catalog/product')
                         ->getCollection()
                         ->addAttributeToSort('name', 'DESC');

Get limited number of products (for example: 10 products) sorted by product name ascending:-

$collection = Mage::getModel('catalog/product')
                         ->getCollection()
                         ->addAttributeToSort('name', 'ASC')
                         ->setPageSize(10);
查看更多
登录 后发表回答