Magento: Set LIMIT on collection

后端 未结 4 1439
甜味超标
甜味超标 2021-02-01 01:58

The question that I tried to find out was how do we set a Limit on a Collection, the answers that I found on Google was only available for the Catalog with a setPage($pageNum, $

4条回答
  •  一生所求
    2021-02-01 02:44

    The way to do was looking at the code in code/core/Mage/Catalog/Model/Resource/Category/Flat/Collection.php at line 380 in Magento 1.7.2 on the function setPage($pageNum, $pageSize)

     $collection = Mage::getModel('model')
         ->getCollection()
         ->setCurPage(2) // 2nd page
         ->setPageSize(10); // 10 elements per pages
    

    I hope this will help someone.

提交回复
热议问题