0

I created a custom module that redirects your homepage to a landing page (CMS Page) that is a campaign page, for example, black friday.

I've created a new layout for the page, layout that uses a phtml to list the products from a category page. The problem is that if I have to many products, nothing listed. It displays only the header and the footer of the website, the content of the cms page is not displayed.

I use this function to load the products:

$products = Mage::getResourceModel('catalog/product_collection')
        ->addCategoryFilter($category_id)
        ->addAttributeToSelect('*');

foreach ($products as $prod) {
    //list product here
}

The single solution until now is if I put the products in more than one category and load the categories in a foreach, like this:

foreach ($catIds as $category_id) {
    $products = Mage::getResourceModel('catalog/product_collection')
        ->addCategoryFilter($category_id)
        ->addAttributeToSelect('*');

    foreach ($products as $prod) {
        //list product here
    }
}

This method works but in my case I need to have all the products in one category.

Is there any way to display a large collection of products on a page? Am I doing something wrong or this just doesn't work because there are to many products? Is there any limit in Magento for getting and displaying so many products from a collection?

2
  • 1
    Check your error logs (both Magento and web server and PHP), it sounds like PHP is running out of memory or otherwise erroring when trying to load and iterate the large collection. There is no hard limit to the number of products that can be loaded, but obviously there are performance and resource considerations.
    – BlueC
    Nov 15, 2019 at 9:25
  • Thanks, meanwhile I found that it is indeed a problem of performance and now I am trying to optimize it...
    – Ciprian
    Nov 15, 2019 at 13:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.