photo credit: Piyushgiri Revagar Old lens via photopin (license)

Import images in Magento 2 – the right way

There are various articles about how to programmatically import images in Magento 2. This method relies solely on service contracts and is in my opinion the “Magento Way” to do it:

Note that we don’t copy our image whatsoever, but make use of an ImageContent object. This is a new layer of abstraction in Magento 2 that allows us to save images regardless of the storage engine that’s behind it.
Assuming there’s a product with SKU ABC123 and an image var/import/foo.jpg:

Visitors give this article an average rating of 3.0 out of 5.

How would you rate this article?

Leave a Reply