How to display a selected simple product's image for configurables in the catalog?

Magento Asked by Alex on August 4, 2020

We import configurables without images, but the simples have images (marked by a special attribute).

How can we show the image of a simples as main image of the configurables (thumbnail, base image)


There seems to be already similar logic in the core:


public function setImageFromChildProduct(MagentoCatalogModelProduct $product)
    if (!$product->getData('image') || $product->getData('image') === 'no_selection') {
        foreach ($this->getUsedProducts($product) as $childProduct) {
            if ($childProduct->getData('image') && $childProduct->getData('image') !== 'no_selection') {
    return parent::setImageFromChildProduct($product);

Problem is that I need something similar for category (product list) pages and I think they do not use the image but the small image.

Add your own answers!

Related Questions

Add Upsell Product On Checkout Cart Page -Magento 2.3

1  Asked on November 25, 2021 by wajahat-banyo


How to setup Magento 2 with Docker

4  Asked on November 23, 2021 by mrto-kane


OpenMage 20.01 – what version of Magento and Supee

1  Asked on November 23, 2021 by hejhog


Magento 2 ElasticSearch Empty Categories

0  Asked on November 23, 2021 by chris-oliver


Magento 2.1 mobile product page doesn’t scroll

2  Asked on November 20, 2021 by alexcr


Invalid Digital Receipt Delivery URL in MIGS integration

1  Asked on November 20, 2021 by shani-tiwari


Ask a Question

Get help from others!

© 2022 All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP