更新时间:2022-02-27 06:42:11
获取按产品名称升序排序的所有产品:-
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');
获取数量有限的产品(例如:10个产品),按产品名称升序排列:-
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);