Display Stock and Out of Stock Products Category Magento

Display Stock and Out of Stock Products Category Magento

August 11, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Display Stock and Out of Stock Products Category Magento

Displaying In Stock and Out of Stock Products in Magento Category Page

As an experienced developer, I understand your frustration when dealing with stock management issues in Magento. Let’s dive into the solution to ensure all products—both in stock and out of stock—are displayed on the category page.

Understanding the Current Issue

You’ve already enabled the option to display out-of-stock products via System > Configuration > Inventory > Stock Options, but it seems the changes are not taking effect. This is likely due to how Magento handles product visibility based on stock status by default.

The key is to manipulate the product collection before its output in your template file. By doing so, you can override the default behavior and ensure all products appear on the category page regardless of their stock levels.

Overriding the Product Collection

To achieve this, we need to override the getLoadedProductCollection method of your Magento controller or block that handles the category view. This will allow us to modify the product collection before it’s rendered in the template.

Here’s an example of how you can do this:

  1. Open your category controller file (usually located at app/code/core/Mage/Catalog/controllers/CategoryController.php).

  2. Find and override the getLoadedProductCollection method:

public function getLoadedProductCollection()
{
    if (!$this->_productCollection) {
        $collection = Mage::getResourceModel($this->getProductCollectionClass())
            ->addStoreFilter($this->getStoreId())
            ->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)
            ->addAttributeToSelect('*');

        if ($this->_productCollection === null) {
            $category = Mage::registry('current_category');
            if ($category && $category->getProductsCount()) {
                $ids = explode(',', $category->getProductCollection()->getAllIds());
                $collection->addIdFilter($ids);
            }
        }

        $this->_productCollection = $collection;
    }

    return $this->_productCollection;
}

In this override, we set the product visibility to both (in stock and out of stock) using setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH). This ensures that all products in the category will be displayed regardless of their current stock status.

Verifying the Solution

After applying this change, you should see all 6 products appearing on your category page—both those with and without quantities. The products marked as out of stock will have a quantity of zero or no quantity displayed at all.

To verify that the solution is working correctly:

  1. Refresh the category page in your frontend.
  2. Check if all 6 products are now visible, even though some may be considered “out of stock” based on the default Magento settings.
  3. Ensure the visibility and stock status attributes are set appropriately for each product in the Magento backend.

Conclusion

In this post, we explored how to override the product collection in your category view to ensure that both in-stock and out-of-stock products are displayed consistently. By following the provided steps and modifying the getLoadedProductCollection method as demonstrated, you should now have all 6 products appearing on your category page.

Remember to always test changes thoroughly after applying them to avoid any unexpected issues during live operations. If you need further assistance with Magento development or customizations, feel free to reach out to our team at Laravel Company.

Happy coding!

Catalog Themes Configuration Errors

Our network