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?