How to use Simple product images for Configurable product images?

How to use Simple product images for Configurable product images?

August 6, 2026 · Illustrated author avatarBy Stefan Bogdanescu
How to use Simple product images for Configurable product images?

Handling Simple Product Images for Configurable Products

As an e-commerce developer, I often encounter situations where clients need their configurable products to dynamically use the images of associated simple products based on stock availability. In this post, we’ll explore how to achieve this functionality in Magento using a combination of configuration and custom development.

Understanding the Problem

The primary challenge is making a configurable product intelligent enough to automatically select an available simple product image as its representative visual when the main color or size option goes out of stock. This ensures that customers always see an accurate representation, even if their desired variant isn’t currently available.

Magento’s Built-in Limitations

Before we dive into solutions, it’s essential to understand that Magento doesn’t natively support this feature. The platform is designed for displaying the primary image associated with a configurable product, regardless of stock status. However, with some creative configuration and customization, we can work around these limitations.

Configurable Product Image Configuration

Firstly, ensure you configure your configurable product correctly:

  1. Go to Catalog > Products.
  2. Select your configurable product and click on the “Configurations” tab.
  3. For each simple product linked to this configuration:
    • Ensure the SKU has inventory available (you can check in the Stock Management section).
    • Make sure the image associated with this simple product is of high quality and fits your design requirements.

Using Simple Product Images

Now, let’s explore two approaches to achieve our goal:

Approach 1: Custom Script for Image Selection

We can create a custom script that runs periodically (e.g., every hour or day) to check the stock levels of associated simple products. Here’s a simplified example using PHP and Magento’s API:

<?php
require 'app/bootstrap.php';

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$stockState = $objectManager->create('\Magento\InventorySalesAdminUi\Model\StockStateProvider');

foreach ($productCollection as $simpleProduct) {
    if ($stockState->isInStock($simpleProduct)) {
        // Update the configurable product image to this simple product's image
        // Note: You'll need to map the configurable product ID and update its image using the Magento API or a custom plugin
    }
}

This script would require integration with the Magento API for retrieving products, checking stock levels, and updating images. It provides a dynamic solution but may have performance implications if not optimized properly.

Approach 2: Dynamic Image Switching Plugin

A more elegant approach involves creating a custom plugin that intercepts image retrieval requests for configurable products. When a configurable product image is requested, the plugin checks if any associated simple product has inventory available and returns its image instead.

However, implementing this requires advanced knowledge of Magento’s Event/Observer system or Dependency Injection plugins. It’s a complex solution that should be handled by experienced developers to ensure thread safety and proper state management.

Conclusion

In conclusion, while Magento doesn’t natively support selecting simple product images for configurable products based on stock availability, it is possible to achieve this functionality through custom development.

The choice between the script-based approach and the plugin-based approach depends on your specific requirements, performance constraints, and technical expertise. Both methods require careful testing to ensure they don’t introduce any data inconsistencies or security vulnerabilities.

For more advanced e-commerce solutions like this one, I recommend reaching out to professional Magento developers or consulting with experts in the field. At Laravel Company, we specialize in complex e-commerce integrations and can help you implement custom solutions tailored to your business needs.

Remember, a well-implemented custom solution can significantly enhance your customers’ shopping experience by ensuring they always see accurate product images, even when their desired options are temporarily out of stock.

Catalog Themes Configuration Customers

Our network