Reputation: 185
I want to get the product collection order by product name in magento? any idea??
Upvotes: 8
Views: 19105
Reputation: 5203
This should help:
$collection = Mage::getModel('catalog/category')->load($categoryId)
->getProductCollection()
->addAttributeToSort('name', 'ASC');
see in Magento Wiki
Upvotes: 3
Reputation: 25968
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);
Upvotes: 9