Magento - load only configurable products

Magento - load only configurable products

July 10, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento - load only configurable products

Optimizing Magento Product Collection Loading: Focusing on Configurables

As an experienced e-commerce developer working primarily with Magento, I often encounter performance challenges when dealing with large product collections. In your specific case, loading all products into memory before filtering for ‘configurable’ types is indeed a major contributor to slow page load times.

Understanding the Current Approach

Your current code snippet first loads all 12000 products and then iterates through them to find the configurable ones. This approach has a significant performance overhead because it’s loading more data than necessary:

$_productCollection = $this->getLoadedProductCollection();

foreach ($_productCollection as $_product)
{
  if ($_product->_data['type_id'] == 'configurable')
  {
    ...
  }
}

Loading Only Configurable Products: A Better Approach

The key to improving performance lies in querying the database directly for only the configurable products you need. Here’s an optimized approach:

// Get the current category ID
$categoryId = $this->getCurrentCategory()->getId();

// Load only configurable products within this category
$collectionConfigurable = Mage::getResourceModel('catalog/product_collection')
                ->addAttributeToFilter('type_id', array('eq' => 'configurable'))
                ->addCategoryFilter($categoryId);

This code directly loads only the configurable products that are part of the current category. The addCategoryFilter method ensures that we’re filtering by the category ID, which significantly reduces the number of products loaded.

Optimizing Further: Using Advanced Filters and Caching

For even better performance, consider using advanced filters and caching mechanisms:

  • Advanced Filters: You can further refine your query by adding additional conditions like price range or stock availability. The addAttributeToFilter method allows for complex filtering operations to reduce the dataset even more.

  • Caching: Implement a caching system for your product collections, especially if you’re loading them frequently. Magento’s built-in cache or third-party solutions can dramatically improve retrieval times by storing and reusing previously loaded data.

Conclusion: Optimizing Magento Performance

In your specific scenario with 12000 products, about 700 of which are configurable:

  • The key to performance is minimizing the amount of data loaded into memory.
  • Directly querying for only the configurable products in the current category is significantly faster than loading all products and filtering them.
  • Advanced filters and caching can further optimize your Magento setup.

Remember that every store has unique requirements, so it’s essential to benchmark and fine-tune your specific implementation based on actual performance data. Regular monitoring of your site’s load times will help ensure optimal user experience even as your product catalog grows.

For more in-depth guides on Magento performance optimization, check out our detailed resource: Magento Speed Optimization Guide at Laravel Company.

Catalog Database Performance Configuration

Our network