{"id":281,"date":"2019-01-04T12:33:32","date_gmt":"2019-01-04T12:33:32","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/2019\/01\/04\/solved-no-image-for-configurable-product-in-magento-2-cart-page\/"},"modified":"2025-07-23T10:11:18","modified_gmt":"2025-07-23T04:41:18","slug":"solved-no-image-for-configurable-product-in-magento-2-cart-page","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/solved-no-image-for-configurable-product-in-magento-2-cart-page\/","title":{"rendered":"Solved: No Image for Configurable Product in Magento 2 Cart Page"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Magento 2 store owners have many options available to optimize the store functionality, improve customer experience, capture payments and ease the administrative tasks with 3rd party extensions. Also, there are 3rd party custom themes available to improve the look and feel of the admin panel and storefront.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The only problem with these 3rd party themes and extensions is that sometimes it disrupts the features of default Magento 2 or conflicts with default configuration.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">One such issue is&nbsp;<em><strong>No Image for Configurable Product in Magento 2 Cart Page<\/strong><\/em>. The simple product image of a configurable product is not displayed in the cart page due to 3rd party extensions or themes.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Generally, the developers follow below steps for fixing the problem:<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Preconditions<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Magento 2.2.x<\/li>\n\n\n\n<li>Create a configurable product.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Steps to Reproduce<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Create a configurable product.<\/li>\n\n\n\n<li>Add images for all child products<\/li>\n\n\n\n<li>Do not add images for parent products.<\/li>\n\n\n\n<li>Add that product in cart page.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">It is expected that images of child product are displayed on cart page. If a child product has no images then images of the parent product are displayed.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Unfortunately, it\u2019s not the case&nbsp;<strong>?&nbsp;<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2018\/12\/Product-image-not-showing-issue-for-configurable-product-1024x457.png\" alt=\"Product image not showing issue for configurable product\" class=\"wp-image-4018\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">To overcome this issue, one needs to override the Magento 2 code file. Let\u2019s see how to do it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Solution: No Image for Configurable Product in Magento 2 Cart Page<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Copy&nbsp;<strong>[MAGENTO_ROOT]vendormagentomodule-catalogBlockProductImageBuilder.php<\/strong>&nbsp;and paste it to&nbsp;<strong>[MAGENTO_ROOT]appcodeMagentoCatalogBlockProductImageBuilder.php&nbsp;<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">find the following code:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">if ($simpleOption !== null)\n \n       {\n            $optionProduct = $simpleOption->getProduct();\n            $this->setProduct($optionProduct);\n        }<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">And, replace it with the below code:<br><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">if ($simpleOption !== null)\n \n        {\n            $optionProduct = $simpleOption->getProduct();\n            $objectManager = MagentoFrameworkAppObjectManager::getInstance();\n            $product = $objectManager->create('MagentoConfigurableProductModelResourceModelProductTypeConfigurable')->getParentIdsByChild($optionProduct->getEntityId());\n            $parentProduct = $objectManager->create('MagentoCatalogModelProduct')->load($product[0]);\n            $this->setProduct($parentProduct);\n        }<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s all you have to do to solve&nbsp;<em>No Image for Configurable Product in Magento 2 Cart Page<\/em>!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The post will be&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/display-product-image-in-order-create-page-in-magento-2\/\">helpful to display the product images<\/a>&nbsp;of the configurable product in Magento 2 cart page.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank You ?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Magento 2 store owners have many options available to optimize the store functionality, improve customer experience, capture payments and ease the administrative tasks with 3rd&#8230;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-281","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/281","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=281"}],"version-history":[{"count":4,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/281\/revisions"}],"predecessor-version":[{"id":19122,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/281\/revisions\/19122"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=281"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=281"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=281"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}