Table of Content

Magmi allows to import images to Magento, use Image attributes processor for this task.

What can do Magmi Image attributes processor:

  • import images, small images, thumbnails and media gallery;
  • import image from both, local path and URLs;
  • include/exclude images for the product;
  • re-name image by pattern;
  • attach labels to images;

Base image columns

  • image
  • small_image
  • thumbnail

Base image label columns:

  • image_label (label to use for image)
  • small_image_label (label to use for small_image)
  • thumbnail_label (label to use for thumbnail image)

Extra images column

  • media_gallery – allows to import as much product images as you want.

Since several images can be set in this column, a specific syntax has been set to handle labels.

  • extended syntax with :: for setting labels only applies to media_gallery column;
  • to set base image label use image label related columns;

media_gallery (extra images) column syntax

 <image1 location>[::image1 label];<image2 location>[::image2 label]
Example without labels
/path/to/extra/img_1.jpg;/path/to/extra/img_2.jpg
Example with labels
/path/to/extra/img_1.jpg::label_text;/path/to/extra/img_2.jpg::label_text

Include/exclude image

By default Magmi marks all images as excluded. Excluded means you will see images in admin panel, but won’t be able to see them on frontend. You should mark images as included manually in admin panel. The simplest way to make the image included just add "+" sign before image path.

+/path/to/extra/img_1.jpg

The opposite to the "+" Magmi uses "-" sign to exclude the image.

-/path/to/extra/img_1.jpg

Image path

Server source

By default, Magmi searches images under media/import path relative to project root directory. It can be changed with Image search path in configuration:
file

URL

Magmi includes really handy helper that allows downloading images directly by URLs. It doesn’t require any configuration, just place full URL instead of relative image path and Magmi automatically download that image from a remote server and will do all manual work.

Image renaming

Sometimes may happens that images placed in different paths but have the same names. Then the collision will happen and the different products can have the same images. To avoid this use Image renaming.

Predefined meta variables

  • {item.sku} – product SKU;
  • {meta.imageindex} – image order index;
  • {meta.imagename.ext} – image extension.

The final renaming rule can have next view:

{item.sku}_{meta.imageindex}.{meta.imagename.ext}

This will rename image to something like this: DD-12345_0.jpg.

Regex

Say your images are located like this:

thumbs/01.png standard/01.png

So you surely have data with columns

image => ‘standard/01.png’ thumbnail => ‘thumbs/01.png’

Since those are not the same images, regex replace may be a good way to "rename" image depending on its container directory.

You can now set the following formula in image renaming:

re::(.*)/(.*)\.(.*)$::$2_$1.$3

Then "standard/01.png" value will be renamed as 01_standard.png in magento and "thumbs/01.png" will be renamed as 01_thumbs.png in Magento, thus avoiding conflicts & overwriting.

Before start, it’s worth nothing that this will not work for images in the “media_gallery” column, only the "image", "small_image" and "thumbnail" columns.

If we look at the example, let’s break this up into pieces:

re::

This says “rewrite”.

The next part:

(.*)/

Is the folder name that is then called by “$1”, eg “thumbs”

The next part:

(.*)

Is the actual image name, eg “01”

And the next part is:

\.(.*)$

Which is the image file name, eg “.jpg”

Then the final part is the rewriting:

::$2_$1.$3

Which in English says “image name” + “_. (underscore and a full stop)” + “folder name” + “extension”

Hence why we go from “thumbs/01.png” to “01_thumbs.png

So if this isn’t working for you, then it is that you’re not just importing a image value similar to “thumbs/01.png” into your small_image etc… columns.

You as well can use predefined variables in regex, for example:

re::.*/(.*)::{item.sku}-$1

FIle example

Only the store and sku columns are required, any others are optional. Below is available full example of CSV file:

store sku image small_image thumbnail media_gallery
admin 001300-9000-BTU +https://example.com/path/to/image.jpg +https://example.com/path/to/image.jpg +https://example.com/path/to/image.jpg +https://example.com/path/to/image.jpg;+https://example.com/path/to/image1.jpg;+https://example.com/path/to/image2.jpg
admin 001300-12000-BTU +https://example.com/path/to/image1.jpg +https://example.com/path/to/image1.jpg +https://example.com/path/to/image1.jpg +https://example.com/path/to/image1.jpg;+https://example.com/path/to/image1_1.jpg;+https://example.com/path/to/image2_1.jpg

Full file example is available in Google Sheets.

Useful links

Last modified: 31.07.2020

Author

Comments

Write a Reply or Comment

Your email address will not be published.