Magento Forum

   
how to import images and media gallery using magento method (and this script)
 
amartinez
Guru
 
Avatar
Total Posts:  347
Joined:  2008-11-14
Spain
 

Hi,

The new AMartinez_CustomImportExport script version (.014) supports single images and media galleries.

How to use this feature?

There’s five new fields:

_media_image
_media_attribute_id
_media_label
_media_position
_media_is_disabled

Please note that you need to indicate the _media_attribute_id, to get it:

Access MAGENTO ADMIN - CATALOG - ATTRIBUTES - MANAGE ATRIBUTES, click “media gallery” attribute to edit it, look at your URL (some like http://www.yourmagento.com/index.php/admin/admin/catalog_product_attribute/edit/attribute_id/77/key/) this URL show you the desired attribute id: 77 in this case

CSV EXAMPLES

test_media_gallery.csv1
Images treated as always (not appear in admin) and imported galleries that YES appears into admin:

"sku""_store""_type""_product_websites""_attribute_set""news_from_date""tipo_articulo""_category""status""visibility""weight""is_in_stock""qty""size""price""delivery_date""tax_class_id""name""short_description""description""_associated_sku""image""small_image""thumbnail""_media_image""_media_attribute_id""_media_label""_media_position""_media_is_disabled"
"TEST1-S1-35"
,,"simple","base","Default","2011-4-8","Shoes","TEST COLLECTION","1","1","1.10","1","999","35","43.90","1899-12-31","2","TEST1-S1 (35)","TEST COLLECTION","TEST COLLECTION",,,,,,,,,
"TEST1-S1-36",,"simple","base","Default","2011-4-8","Shoes","TEST COLLECTION","1","1","1.10","1","999","36","43.90","1899-12-31","2","TEST1-S1 (36)","TEST COLLECTION","TEST COLLECTION",,,,,,,,,
"TEST1-S1-37",,"simple","base","Default","2011-4-8","Shoes","TEST COLLECTION","1","1","1.10","1","999","37","43.90","1899-12-31","2","TEST1-S1 (37)","TEST COLLECTION","TEST COLLECTION",,,,,,,,,
"TEST1-S1",,"grouped","base","Default","2011-4-8","Shoes","TEST COLLECTION/SUBTEST,MALICIA","1","4","1.10","1","13986","","43.90","1899-12-31","2","TEST 1  ANTIK NEGRO, PISO TEST test","TEST COLLECTION","TEST COLLECTION","TEST1-S1-35,TEST1-S1-36,TEST1-S1-37","/img_articulos/TEST1-S1.jpg","/img_articulos/TEST1-S1.jpg","/img_articulos/TEST1-S1.jpg","/img_articulos/TEST1-S2.jpg,/img_articulos/TEST1-S3.jpg,/img_articulos/TEST1-S4.jpg","77,77,77",,,

test_media_gallery_and_base_image.csv1
Images and galleries imports and appears into admin:

"sku""_store""_type""_product_websites""_attribute_set""news_from_date""tipo_articulo""_category""status""visibility""weight""is_in_stock""qty""size""price""delivery_date""tax_class_id""name""short_description""description""_associated_sku""image""small_image""thumbnail""_media_image""_media_attribute_id""_media_label""_media_position""_media_is_disabled"
"TEST1-S1-35"
,,"simple","base","Default","2011-4-8","Shoes","TEST COLLECTION","1","1","1.10","1","999","35","43.90","1899-12-31","2","TEST1-S1 (35)","TEST COLLECTION","TEST COLLECTION",,,,,,,,,
"TEST1-S1-36",,"simple","base","Default","2011-4-8","Shoes","TEST COLLECTION","1","1","1.10","1","999","36","43.90","1899-12-31","2","TEST1-S1 (36)","TEST COLLECTION","TEST COLLECTION",,,,,,,,,
"TEST1-S1-37",,"simple","base","Default","2011-4-8","Shoes","TEST COLLECTION","1","1","1.10","1","999","37","43.90","1899-12-31","2","TEST1-S1 (37)","TEST COLLECTION","TEST COLLECTION",,,,,,,,,
"TEST1-S1",,"grouped","base","Default","2011-4-8","Shoes","TEST COLLECTION/SUBTEST,MALICIA","1","4","1.10","1","13986","","43.90","1899-12-31","2","TEST 1  ANTIK NEGRO, PISO TEST test","TEST COLLECTION","TEST COLLECTION","TEST1-S1-35,TEST1-S1-36,TEST1-S1-37","/img_articulos/TEST1-S1.jpg","/img_articulos/TEST1-S1.jpg","/img_articulos/TEST1-S1.jpg","/img_articulos/TEST1-S1.jpg,/img_articulos/TEST1-S2.jpg,/img_articulos/TEST1-S3.jpg,/img_articulos/TEST1-S4.jpg","77,77,77,77",,,

Please upgrade to new version. I would appreciate your comments!

Image Attachments
media gallery 2.jpgmedia gallery 1.jpgmedia gallery and image 1.jpgmedia gallery and image 2.jpg
 
Magento Community Magento Community
Magento Community
Magento Community
 
remik
Jr. Member
 
Total Posts:  2
Joined:  2011-08-26
 

Hello.

Great script. It really is very useful. I have a quick question. I am trying to import images, but nothing gets imported. I was putting my images in /media/import and /media/catalog folders and tried different paths in CSV, but all my products get imported with no images.

In Your example You set path to /img_articulo/XXX.jpg, please tell me where in folder structure is img_articulo located. Thanks in advance and keep the good work.

Regards,
Remik

Just found an answer at: http://www.magentocommerce.com/boards/viewthread/236243/

 
Magento Community Magento Community
Magento Community
Magento Community
 
PCProffitt
Jr. Member
 
Total Posts:  4
Joined:  2009-07-10
Suwanee, GA, USA
 

From my limited experience the folder should be media/catalog/product/[your image folder].  Then [your image folder] is what you put in the import CSV file column.

For example if your import CSV file \\\’image\\\’ column is: /myfolder/myimage.jpg
Then your folder structure should be media/catalog/product/myfolder/myimage.jpg

 
Magento Community Magento Community
Magento Community
Magento Community
 
remik
Jr. Member
 
Total Posts:  2
Joined:  2011-08-26
 

Hi again.

It seems that the path was not the problem. I modified the file “app/code/community/AMartinezCustomImportExport/Model/Import/Entity/Product.php” to give me some debug data and this is what I found:

SQLSTATE[23000]Integrity constraint violation1048 Column 'disabled' cannot be null

When not setting any value for disabled field it was set to null and this throws an SQL error. I have modified my CSV to look like this:

"sku","_product_websites","_type","_attribute_set","_category","kod_kreskowy","stan_magazynowy","status","visibility","is_in_stock","qty","manufacturer","price","tax_class_id","name","short_description","description","image","small_image","thumbnail","_media_image","_media_attribute_id","_media_label","_media_position","_media_is_disabled"
"CL005-BLK"
,"base","simple","Default",,"4890808018675","bardzo dużo",,"4","1","50","ELECTRIC LINGERIE","38.861788617886","2","CL005-BLK Sexy Seductress Dress","Mini sukienka z głębokim dekoltem. Rozmiar uniwersalny. ","Mini sukienka z głębokim dekoltem. Rozmiar uniwersalny. ","/Clubwear/CL005-BLK.jpg","/Clubwear/CL005-BLK.jpg","/Clubwear/CL005-BLK.jpg","/Clubwear/CL005-BLK.jpg,/Clubwear/CL005-BLK_1.jpg","80,80","Zdjęcie 1,Zdjęcie 2",,"0,0"

This is a .csv1 file and according to the instruction photos should be spawned between multiple lines. This happens, but only the first image gets disabled="0,0" and the other fields get disabled=null, which throws the error again.

Therefore I made a small fix to set disabled=0 by default. Below is a modified line no 176 from file “app/code/community/AMartinezCustomImportExport/Model/Import/Entity/Product.php”:

'disabled' => '0' //$insertValue['disabled']

New version of import tool should probably fix this in a better fashion (for instance by allowing usage of _media_disabled = “0,0").

btw. I am using the newest Magento 1.6.0.0

--
Regards,
Remik

 
Magento Community Magento Community
Magento Community
Magento Community
 
Bing Dicklepuss
Sr. Member
 
Total Posts:  91
Joined:  2010-07-26
 
remik - 30 August 2011 12:25 PM

Hi again.

It seems that the path was not the problem. I modified the file “app/code/community/AMartinezCustomImportExport/Model/Import/Entity/Product.php” to give me some debug data and this is what I found:

SQLSTATE[23000]Integrity constraint violation1048 Column 'disabled' cannot be null


When not setting any value for disabled field it was set to null and this throws an SQL error. I have modified my CSV to look like this:

"sku","_product_websites","_type","_attribute_set","_category","kod_kreskowy","stan_magazynowy","status","visibility","is_in_stock","qty","manufacturer","price","tax_class_id","name","short_description","description","image","small_image","thumbnail","_media_image","_media_attribute_id","_media_label","_media_position","_media_is_disabled"
"CL005-BLK"
,"base","simple","Default",,"4890808018675","bardzo dużo",,"4","1","50","ELECTRIC LINGERIE","38.861788617886","2","CL005-BLK Sexy Seductress Dress","Mini sukienka z głębokim dekoltem. Rozmiar uniwersalny. ","Mini sukienka z głębokim dekoltem. Rozmiar uniwersalny. ","/Clubwear/CL005-BLK.jpg","/Clubwear/CL005-BLK.jpg","/Clubwear/CL005-BLK.jpg","/Clubwear/CL005-BLK.jpg,/Clubwear/CL005-BLK_1.jpg","80,80","Zdjęcie 1,Zdjęcie 2",,"0,0"

This is a .csv1 file and according to the instruction photos should be spawned between multiple lines. This happens, but only the first image gets disabled="0,0" and the other fields get disabled=null, which throws the error again.

Therefore I made a small fix to set disabled=0 by default. Below is a modified line no 176 from file “app/code/community/AMartinezCustomImportExport/Model/Import/Entity/Product.php”:
'disabled' => '0' //$insertValue['disabled']



New version of import tool should probably fix this in a better fashion (for instance by allowing usage of _media_disabled = “0,0").

btw. I am using the newest Magento 1.6.0.0

--
Regards,
Remik

I would also recommend you try importing the images separately from the other data to avoid conflicts.
When I import images I generally just include these columns:
“sku”,"_store”,"_product_websites”,"status”,"image”,"small_image”,"thumbnail”,"_media_image”,"_media_attribute_id”,"_media_label”,"_media_position”,"_media_is_disabled"

You include the main image also in the “_media_image” column.  And for every image listed under “_media_image”, I include matching values under the subsequent columns.

E.g.

“sku”,"_store”,"_product_websites”,"status”,"image”,"small_image”,"thumbnail”,"_media_image”,"_media_attribute_id”,"_media_label”,"_media_position”,"_media_is_disabled"
“SKU-61025”,,"base”,1,"/images/6/1/SKU-61025.jpg”,"/images/6/1/SKU-61025.jpg”,"/images/6/1/SKU-61025.jpg”,"/images/6/1/SKU-61025.jpg,/images/6/1/SKU-61025_alternate_image.jpg”,"77,77","61025 Main Image Label,61025 Alternate Image Label”,"1,2”,"1,0"

 
Magento Community Magento Community
Magento Community
Magento Community
 
emmenko
Sr. Member
 
Total Posts:  96
Joined:  2010-10-20
 

Hi everybody,

first of all thx one more time to AMartinez for his great work that he has done and he is doing for the community.

My problem is kind of strange and I like to share that with all of you.
So I started yesterday to test the last version of magento 1.6.0.0. I was expecting (I always worked until now with the version 1.4.1.1) a brand new import/export system and at first I was pretty satisfied with the UI.
So I created a conf product and exported it to see what the csv looked like...a lot of new columns!! And many attributes with an underscore.
There were a few things that I didn’t know how to use them, so I googled and I found immediately the Extension of AMartinez.
This made me think:
1- an extension from AMartinez, wow great! So there should be no problem with the import this time (’cause you know, one of the biggest problem of magento, in my opinion, is the poor import/export system)
2- ...wait, AMartinez still has to fix the code to be able to import some products with their images??! So in the end nothing changed so far....

So I gave it a try with the magento import but I had some issue to make a clear import (maybe because of the new attributes or because there is no guide on how to use it and what the attributes are for).
I then installed the AMartinez extension and looked at the examples.
After a few tries I was able to import products. But no images were imported. Also the category wasn’t selected. What??
I looked at the frontend and the products were there, with images and the fact that they were there ment that they were saved in the category.
But why in backend images and category weren’t shown up?

I tried also to import with the magento-import and it was the same: images were shown in frontend but not in backend. WTF?
Then I found out that in the _media_image I have to write one image per cell, so it would be like that:

_media_image
/images/Edition_1.jpeg
/images/Jug_Optimax_white_detail_03_385x325.jpeg

So basically the situation is this one:
- I installed the AMartinez extension
- I placed the images in the directory

/media/catalog/product/images
- it’s the same if I import with the magento-import or the AMartinez script (and yes, I use it with .csv1)
- I have just one root category (STORE A) and in the frontend I can see the products in this category but when I look at the backend, the category contains no product

This is my csv

"sku","_store","_product_websites","_type","_attribute_set","_category","status","visibility","weight","tax_class_id","is_in_stock","qty","size","color","price","name","short_description","description","_super_products_sku","_super_attribute_code","image","small_image","thumbnail","_media_image","_media_attribute_id","_media_label","_media_position","_media_is_disabled"
"BRITA-01"
,,"base","configurable","Default","STORE A",1,4,2,0,1,,,,69,"BRITA WASSERFILTER","Short Description","Description ","BRITA-M-red","size","/images/Jug_Optimax_white_detail_03_385x325.jpeg","/images/Edition_1.jpeg","/images/Jug_Optimax_white_detail_03_385x325.jpeg","/images/Edition_1.jpeg",80,"Brita Wasserfilter",1,0
,"store_b_en",,,,,,1,,,,,,,,,,,"BRITA-L-red","color",,,,"/images/Jug_Optimax_white_detail_03_385x325.jpeg",80,"Brita Wasserfilter",2,0
,,,,,,,,,,,,,,,,,,"BRITA-M-white",,,,,,,,,
,,,,,,,,,,,,,,,,,,
"BRITA-L-white",,,,,,,,,
"BRITA-M-red",,"base","simple","Default","STORE A",1,1,2,0,1,50,"M","red",69,"BRITA -M-red","Short Description","Description ",,,,,,,,,,
"BRITA-L-red",,"base","simple","Default","STORE A",1,1,2,0,1,50,"L","red",69,"BRITA-L-red","Short Description","Description ",,,,,,,,,,
"BRITA-M-white",,"base","simple","Default","STORE A",1,1,2,0,1,50,"M","white",69,"BRITA-M-white","Short Description","Description ",,,,,,,,,,
"BRITA-L-white",,"base","simple","Default","STORE A",1,1,2,0,1,50,"L","white",69,"BRITA-L-white","Short Description","Description ",,,,,,,,,,

Someone has an explanation on that?
Thanks in advance

 
Magento Community Magento Community
Magento Community
Magento Community
 
FMEExtensions
Mentor
 
Avatar
Total Posts:  1140
Joined:  2009-08-07
 

To include Media Gallery functionality into magento try the following magento module

http://www.fmeextensions.com/media-gallery.html

 
Magento Community Magento Community
Magento Community
Magento Community
 
SFSF99
Jr. Member
 
Avatar
Total Posts:  7
Joined:  2011-01-02
 

Dear AMartinez,

Thank you very much for your free extension, I am sure it took a lot of work and time for you.

In my experience it did not work (or has worked but not anymore in your last version) for categories and images in the normal way (so .csv) but also not for a .csv1 excel sheet.

So I use your extension only for updating products (categories and images can be changed by the webshop owner) and than it goes unbelieveable speedy.

Their are some problems if you can’t provide all fields (it’s a update, so sku must be enough) but that I have to figure out.

When I create products I use the Magento api’s (without Soap, see described by Alan Storm) and that takes 2-3 seconds for each product but you can do all what you want. If you run such a program daily their are only a few new products, so no problem.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top