Magento – Changing cart image based on cart item

cartmagento2magento2.2.2mini-cart

I am trying to change the cart image based on my cart item configuration. But it seems like Magento\Checkout\Block\Cart\Item\Renderer::getImage receives the original Product model class and not the cart item product.

When adding the item to the cart I have added custom data with $product->addCustomOption('my_option', $data) and in $data is a generated base64 encoded image of the product. Which I would like to display in the cart and minicart.

Any ideas on how to solve this?

Best Answer

I don't understood well the question, but if you want to change which product's image of configurable product will be showed in cart and minicart, in latest Magento version you can do it in: Store-> Configuration-> Sales-> Checkout-> Shopping Cart-> Configurable Product Image Where you can choose between: Product Thumbnail Itself or Parent Product Thumbnail

Related Topic