Magento: Set LIMIT on collection

后端 未结 4 1463
甜味超标
甜味超标 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:49

    You can Implement this also:- setPage(1, n); where, n = any number.

    $products = Mage::getResourceModel('catalog/product_collection')
                    ->addAttributeToSelect('*')
                    ->addAttributeToSelect(array('name', 'price', 'small_image'))
                    ->addFieldToFilter('visibility', Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH) //visible only catalog & searchable product
                    ->addAttributeToFilter('status', 1) // enabled
                    ->setStoreId($storeId)
                    ->setOrder('created_at', 'desc')
                    ->setPage(1, 6);
    

提交回复
热议问题