Magento - get product collection of all products

Magento - get product collection of all products

September 23, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento - get product collection of all products

Magento: Retrieving a Product Collection of All Products

Are you facing challenges when trying to create a custom product collection that includes every single item listed on your Magento store? You’re not alone! Let’s dive into a step-by-step solution for obtaining a complete product list without the need for an additional category.

The Current Situation and Your Requirements

You have a vast store with 8000 products spread across various categories. Adding all these to one extra category is impractical due to size limitations. You want to display a comprehensive product collection on a specific CMS page, regardless of their assigned categories.

Your current approach involves a block call on the CMS page:

{{block type="catalog/product_list" template="catalog/product/list.phtml"}}

You’ve already created a module to override the Mage_Catalog_Block_Product_List class and identified the _getProductCollection() function as the target for your modifications.

Overriding _getProductCollection() Function

To achieve this, you need to modify the overridden _getProductCollection() function in your custom block. Here’s how:

  1. First, make sure you have properly configured your module by creating a file named config.xml under app/code/local/YourCompany/YourModule/etc. This file should contain the necessary block type overrides:
<blocks>
    <catalog>
        <rewrite>
            <product_list>YourCompany_YourModule_Block_Catalog_Product_List</product_list>
        </rewrite>
    </catalog>
</blocks>
  1. Next, create a new file named List.php under app/code/local/YourCompany/YourModule/Block/Catalog. In this file, extend the core Mage_Catalog_Block_Product_List class and override the _getProductCollection() function:
class YourCompany_YourModule_Block_Catalog_Product_List extends Mage_Catalog_Block_Product_List
{
    public function _getProductCollection()
    {
        $collection = Mage::getResourceModel('catalog/product_collection');
        $collection->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes());
        $collection->setCurPage($this->getCurrentPage());

        return $collection;
    }
}

Key Steps in the Solution

  • We start by creating a new configuration file (config.xml) to define our block type rewrite.
  • Next, we create a custom block class (List.php), extending the core product list block and overriding the _getProductCollection() function.

What Happens Inside _getProductCollection()

The overridden function:

  1. Retrieves a generic catalog/product_collection instance using the resource model.
  2. Selects all relevant attributes for the products in this collection based on the Magento configuration.
  3. Sets the current page number for pagination purposes, if required.

Conclusion: All Products at Your Fingertips

By following these steps and implementing this solution, you’ll be able to display a complete product list on any CMS page without needing to create an additional category. This approach provides a clean and efficient way to handle large product collections in Magento.

Remember, proper module configuration is crucial for successful block overrides. Always ensure your custom code adheres to Magento’s best practices and avoid performance overheads by using the resource model correctly.

For further insights into Magento development and optimization techniques, feel free to explore our blog at LaravelCompany.

Catalog Extensions Themes Configuration

Our network