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? any idea??

2 thoughts on “how to get all product collection order by product name in magento?”

  1. 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);
    

Leave a Reply

Your email address will not be published. Required fields are marked *