2

I am using Magmi to import products into Magento.

I upload all images to local folder (media/import) where files are either .jpg or .gif.

Images are named:

[sku.jpg] OR [sku.gif]

I have now configured Magmi so it imports all jpg images and this works fine.

This is how my CSV looks (only image columns):

image,small_image,thumbnail
sku,sku,sku

I am then using "value replacer" plugin to insert .jpg behind every sku in image columns. This also works fine. enter image description here

Is it possible to also search for .gif in same import, so it either finds a sku with file extension .jpg or .gif ?

Josua Marcel C
  • 3,122
  • 6
  • 45
  • 87
puntable
  • 299
  • 6
  • 19

1 Answers1

1

This is untested, but I'm sure you'd be able to do something like this:

+{{ (file_exists({item.sku} . '.gif') ? {item.sku} . '.gif' : {item.sku} . '.jpg') }}

I don't know the full location of the images, so it might need tweaking a bit, but the idea behind it should be correct.

Karl
  • 5,435
  • 11
  • 44
  • 70
  • I tried but i get this error: "SKU testsku- Image attributes processor v1.0.33 - testsku.jpg cannot be found in images path" if only a gif image is in image folder. – puntable Sep 24 '15 at 18:34
  • Like I said, you may need to tweak the part in the file_exists() call so that it looks in the correct directory. – Karl Sep 24 '15 at 19:48
  • The gif file is in same directory as the jpg file. Only 2 image files in folder, just renamed the jpg to see if it works. – puntable Sep 24 '15 at 20:44
  • Well the only way it would try and use the .jpg is if the .gif doesn't exist. So you'll need to start your search from there. – Karl Sep 24 '15 at 20:57
  • Did you manage to solve this? What you need to do is make sure that the `file_exists({item.sku} . '.gif')` points to the correct directory e.g. `file_exists('/media/import/' . {item.sku} . '.gif')`. – Karl Oct 05 '15 at 10:56
  • 1
    I finally got it working with your solution. I needed to add absolute path. Working solution is like this: +{{ (file_exists('/var/www/mysite.com/public_html/media/import/' . {item.sku} . '.gif') ? {item.sku} . '.gif' : {item.sku} . '.jpg') }} – puntable Oct 05 '15 at 14:29
  • How can I import products images for multi-store, may i know csv header columns – Gem Aug 08 '17 at 08:48