[英]how to get all product collection order by product name in magento?
I want to get the product collection order by product name in magento? 我想在magento中按产品名称获取产品系列订单? any idea?? 任何想法??
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:- 获得有限数量的产品(例如:10种产品),按产品名称升序排序: -
$collection = Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSort('name', 'ASC')
->setPageSize(10);
This should help: 这应该有所帮助:
$collection = Mage::getModel('catalog/category')->load($categoryId)
->getProductCollection()
->addAttributeToSort('name', 'ASC');
see in Magento Wiki 参见Magento Wiki
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.