I have a custom module setup where child images are added to cart instead of their configurable parents. This works great. I'm now looking to add the child images to Cart, Minicart and Order Summary. I'm using this to get the image url and send it to the frontend:

$imageUrl = $this->imageHelper->init($_product, 'cart_page_product_thumbnail')->getUrl();

This works for simple products. However, when I have two simple products from a configurable added to the cart, it shows the same image for both and not their own. I am retrieving the product id as such:

  $_product = $this->productModel->load($productId);  
  $product = $_product->getId();

And I can see the product ID is correct. I think perhaps I need to retrieve the item ID rather than product ID but I'm unsure.

Note that the Configurable Product Image setting in Stores > Settings Configuration > Sales > Checkout makes no difference here as I'm overriding that.

Any ideas?

  • I thought that this is default Magento feature :?
    – HoangHieu
    Commented Nov 21, 2023 at 7:55

2 Answers 2


If you already have product model then you can call $product->getThumbnail() to the image of the product. Note that it would not give the full path to the image. You can get full path using

$fullImageUrl = $block->getUrl('pub/media/catalog').'product'.$product->getThumbnail()


If you are working with helpers then all helpers already extend \Magento\Framework\App\Helper\AbstractHelper so you can use following code instead

$fullImageUrl = parent::_getUrl('pub/media/catalog').'product'.$product->getThumbnail()
  • Unfortunately retrieving via $block doesn't work here as it's a custom helper function I'm writing. Commented Nov 21, 2023 at 15:14
  • You can use parent::_getUrl instead, check edit. Commented Nov 22, 2023 at 4:42
  • I get an output of "no_selection" for this. Thumbnail is set on the parent product. Image path it gives is pub/media/catalog/no_selection Commented Nov 22, 2023 at 14:18

Actually there's a configuration for this, go to

Admin->Stores->Configuration->Sales->Checkout->Shopping Cart

Find Configurable Product Image and change it to Product Thumbnail Itself

Hope this works for you :)

  • As I said in my original post, this setting is irrelevant as I'm overriding that with the module. Commented Dec 7, 2023 at 12:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.