Magento load product collection including disabled products

Magento load product collection including disabled products

July 8, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento load product collection including disabled products

Understanding Disabled Products in Magento

Are you facing challenges when trying to load a product collection that includes disabled products in your Magento store? You’re not alone! Let’s dive into this common issue and explore solutions.

The Default Behavior: Ignoring Disabled Products

By default, the Magento product collection does indeed ignore any products with the status set to “disabled”. The system filters these out automatically when you use the standard getCollection() method to retrieve your collections. This is done for performance reasons - disabled products are typically not visible on the frontend and shouldn’t be included in most queries.

$collection = Mage::getModel('catalog/product')->getCollection();

Solution 1: Using a Specific Attribute

To filter by product status, you can use the status attribute directly. Here’s how to load only disabled products:

$disabledProducts = Mage::getResourceModel('catalog/product_collection')
    ->addAttributeToFilter('status', array('eq' => Mage_Catalog_Model_Product_Status::STATUS_DISABLED));

Solution 2: Using an Event Observer

If you need to modify the behavior globally, consider using a Magento event observer. You can listen for the core_resource_init or catalog_product_collection_load_before events and modify the collection filter accordingly.

public function addDisabledProducts($observer)
{
    $collection = $observer->getEvent()->getCollection();
    $collection->addAttributeToFilter('status', array('eq' => Mage_Catalog_Model_Product_Status::STATUS_DISABLED));
}

Why Magento Ignores Disabled Products

There are several reasons why Magento doesn’t include disabled products by default:

  1. Performance: Disabled products are typically not needed in most queries, so excluding them reduces the size of each collection.

  2. Security: Disabled products may contain outdated or insecure data that shouldn’t be accessed without explicit permission.

  3. Frontend Visibility: Most frontend controllers and blocks don’t display disabled products to customers by default.

Conclusion

In summary, while Magento’s default behavior is to exclude disabled products for performance and security reasons, there are straightforward ways to include them in your collections when necessary. Whether you use direct attribute filtering or event observers depends on your specific requirements.

Remember, every change should be thoroughly tested before deploying it to a live environment. If you’re looking for more advanced Magento solutions tailored to your business needs, feel free to reach out to our team at Laravel Company.

We’ve seen many scenarios like this and can provide expert guidance to optimize your Magento store’s performance and security. Don’t hesitate to contact us for a consultation!

Catalog Performance Extensions Errors

Our network