cancel
Showing results for 
Search instead for 
Did you mean: 

Images not showing in mini-cart

Images not showing in mini-cart

Hi,

Using Magento 2.4

 

I have a script which is importing products and adding images to each product.

Everything seems to be working quite well but I experience issues with the mini-cart.

 

To import the images I use the following:

 

$img = "path/to/image.png";

$product->addImageToMediaGallery(
        $img,
        [
            'image',
            'small_image',
            'thumbnail',
        ],
        false,
        false
);

The issue definitely appears if I flush the image cache before the import (even a few hours or a day before):

 

Admin Dashboard > System > Cache Management --> then scroll down to "Flush Catalog Image Cache"

 

After import the product appears on the front-end with its image, but if I add it to the cart I only see the placeholder in the mini-cart, not the actual image.

 

Does anyone have an idea of why this is happening?

Any help would be highly appreciated.

 

UPDATE:

Let me rephrase my question:

If you had to import many products (4000) programmatically every day and you want to make sure that the image for each product is updated correctly each day in case it has changed from one day to the next - how would you solve this?

Given is:

  • the name of the image for each product
  • the images are placed in an image folder before daily import

Thanks again for any idea or solution

 

Thanks

Jerome