🔥 Just Launched! Werra Premium Template for HyväSee it in Action

How to Get Page Wise Products Collection in Magento

By Sanjay JethvaUpdated on May 22, 2025 1 min read

If you own a Magento online store, it is important that you design the store and its navigational features that make it easy for visitors to find the products they want and shop easily.

When you offer a large number of products, it is not possible to display all of them at once. Also, loading all products at once takes time which results in script time-out.

The solution to the problem is load products on scroll or display page wise products collection. Here I’ll give the solution to get page wise products collection in Magento.

Example to Get Page wise Products Collection in Magento:

$p = 0;
    while (1) {
        $p++;
        $products = Mage::getModel('catalog/product')
            ->getCollection()
            ->addAttributeToSelect('*')
            ->setPageSize(200)
            ->setCurPage($p)
            ->setOrder('id', 'ASC')
            ->addAttributeToFilter('status', array('eq' => '1'));
            
            foreach ($products as $_product) {
                echo '<br>'.$_product->getId();
            }
            
            if ($p >= $products->getLastPageNumber()) {
                break;
            }
    }

When fetching product collections page-wise in Magento, managing the number of items displayed per page is important. You can achieve that using the setPageSize method in Magento 2 collections.

Hopefully, the above example helps you to get the solution.

Thanks!

Sanjay Jethva Full Image
Article bySanjay Jethva

Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe. His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.