B-219 Sec-55 Noida, India
+918010221733

How to limit the collection of a model in Magento

In this post, I will show you how to limit the collection of a Model in Magento. I will use catalog product module for this example.

First, you can use setPageSize() method for setting number of items you want to display in one page.

    Mage::getModel(‘catalog/product’)->getCollection()
       ->setPageSize(10);

The second example is to display 10 items from a 5th item

    $start = 5;
    $limit = 10;
    $collection = Mage::getModel(‘catalog/product’)->getCollection();
    $collection->getSelect()
       ->limit($limit,$start);

(Visited 53 times, 1 visits today)

Leave a reply

You must be logged in to post a comment.