Skip to content

Change Order Summary Image

I’ve been working on a module to change Magento Thumbnails in the Cart, Minicart and Checkout Order Summary.
The only place I cannot get this to work is the Checkout Order Summary. There is a real lack of documentation on how to modify the image thumbnails there.

So far, I have:

<?php

namespace ConfigurableProductsPlugin;

use MagentoCheckoutModelCartImageProvider;
use MagentoCatalogBlockProductAbstractProduct;
use MagentoQuoteModelQuoteItemFactory;
use MagentoCheckoutModelSession as CheckoutSession;
use MagentoCheckoutCustomerDataDefaultItem;

class afterGetImages
{
  protected $itemFactory;
  public function __construct(
    MagentoSalesModelOrderItemFactory $itemFactory,
  ) {
    $this->itemFactory = $itemFactory;
 }
public function afterGetImages(ImageProvider $subject, array $result): array
 {

 
    foreach ($result as $itemId => $value) {
      /** @var MagentoQuoteModelQuoteItem $item **/
      $item = $this->itemFactory->create()->load($itemId);
        if ($item) {
          $productid = $item->getProduct();
        }

    }
 }
}

But this returns:

Return value must be of type array, none returned on line 31

It does not seem to be fetching the data correctly.

Secondly, I can find no information of what argument to modify to change the Order Summary Checkout Image.
Looking at magento/module-checkout/Model/Cart/ImageProvider.php, it includes:

$imageData = [
    'src' => $imageHelper->getUrl(),
    'alt' => $imageHelper->getLabel(),
    'width' => $imageHelper->getWidth(),
    'height' => $imageHelper->getHeight(),
];
return $imageData;

But including this logic in my function:

$imageData = [
            'src' => "Image Url",
        ];
        return $imageData;

Does not change the image.
I’ve spend many days on this but I keep hitting a brick wall.
What needs to be changed here to modify the Checkout Order Summary Thumbnails?
I found this thread but it didn’t seem to change Order Summary Thumbnails for me.

Thank you.