Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Poll
Were you able to import images into your Magento store via csv or XML
Yes 122
No 250
Total Votes: 372
You must be a logged-in member to vote
Image Import—Does It Work? 
 
vikshu
Member
 
Total Posts:  69
Joined:  2009-04-09
Noida
 
AJ Tarachanowicz - 20 February 2009 07:17 AM

The reason why the images are set to ‘excluded’ is because at the very bottom of the saveRow() function in app/code/core/Mage/Catalog/Model/Convert/Adapter/Product.php there is a call to $product->addImageToMediaGallery(Mage::getBaseDir(’media’) . DS . ‘import’ . $file, $fields); The method addImageTOmediagallery*() by default has the exclude parameter set to true. I’d say that this is probably a bug an someone should file a bug report

So how do i correct it, i have around 250 products uploaded on m site and all have this excluded thing in it. Please suggest.
Thanks in advance

 
Magento Community Magento Community
Magento Community
Magento Community
 
Daniel Nordstrom
Jr. Member
 
Avatar
Total Posts:  10
Joined:  2009-06-24
 
vikshu - 23 June 2009 09:03 PM

AJ Tarachanowicz - 20 February 2009 07:17 AM
The reason why the images are set to ‘excluded’ is because at the very bottom of the saveRow() function in app/code/core/Mage/Catalog/Model/Convert/Adapter/Product.php there is a call to $product->addImageToMediaGallery(Mage::getBaseDir(’media’) . DS . ‘import’ . $file, $fields); The method addImageTOmediagallery*() by default has the exclude parameter set to true. I’d say that this is probably a bug an someone should file a bug report

So how do i correct it, i have around 250 products uploaded on m site and all have this excluded thing in it. Please suggest.
Thanks in advance

I’m guessing that’s what rickygri is doing in step 3 right above your original post. If I’m correct, a reimport should get it right with that code change.

If reimport is not an option, I’d check out the database and try to find where the exclude flag is stored and then write an SQL query to fix it. Haven’t worked with Magento long enough to give any concrete guideline on that though.

 
Magento Community Magento Community
Magento Community
Magento Community
 
rickygri
Jr. Member
 
Total Posts:  22
Joined:  2009-01-17
 

Alright Vikshu,

I’ve included an example csv in my post from before, as Daniel says, following step 3 should include image import.
Hope this helps.

Rick

 
Magento Community Magento Community
Magento Community
Magento Community
 
vikshu
Member
 
Total Posts:  69
Joined:  2009-04-09
Noida
 

I’m guessing that’s what rickygri is doing in step 3 right above your original post. If I’m correct, a reimport should get it right with that code change.

If reimport is not an option, I’d check out the database and try to find where the exclude flag is stored and then write an SQL query to fix it. Haven’t worked with Magento long enough to give any concrete guideline on that though.

Hi Thanks a lot,
i tried reimporting and it worked. Thanks a lot.
But have noticed another error. i now have duplicate image in all the products. Please see the attached image. i know there must be some tweek for it too. Please suggest. Thanks a lot in advance.

Image Attachments
20090624_171923.png
 
Magento Community Magento Community
Magento Community
Magento Community
 
rickygri
Jr. Member
 
Total Posts:  22
Joined:  2009-01-17
 

Did you follow step 3 to change the exclude rule? -

3. In “app/code/core/Mage/Catalog/Model/product.php”, on (or near) line 759 change:

public function addImageToMediaGallery($file$mediaAttribute=null$move=false$exclude=true)

to:

public function addImageToMediaGallery($file$mediaAttribute=null$move=false$exclude=false)

As far as I know, this should fix the exclude problem.
Let me know how you get on.

Rick

 
Magento Community Magento Community
Magento Community
Magento Community
 
vikshu
Member
 
Total Posts:  69
Joined:  2009-04-09
Noida
 
rickygri - 24 June 2009 03:12 AM

Did you follow step 3 to change the exclude rule? -

3. In “app/code/core/Mage/Catalog/Model/product.php”, on (or near) line 759 change:

public function addImageToMediaGallery($file$mediaAttribute=null$move=false$exclude=true)

to:

public function addImageToMediaGallery($file$mediaAttribute=null$move=false$exclude=false)

As far as I know, this should fix the exclude problem.
Let me know how you get on.

Rick
+

Hi Rick

I was able to solve the exclude issue by reloading the csv file and creating a new profile. Thanks . I though have changed the codes as quoted by you. The problem i now have is that all my porducts have a copy of the same images which were previously there. i think it is because i ran the profile again . I hope you are getting me .
There must be some way for it too. Please suggest.

Also Do i need to upload new csv everytime i want some changes in my product attributes?

Or can i just download the previously uploaded csv file, add the required attribute to it, upload it back to its location i.e var/import and then go to the Manage product and update attributes. 
If not then what should be the error free way to do it.

Thanks a lot Rick .

 
Magento Community Magento Community
Magento Community
Magento Community
 
rickygri
Jr. Member
 
Total Posts:  22
Joined:  2009-01-17
 

No problem!

As far as I know, if you upload a csv where the sku’s are the same as already present, each column’s data will replace the old ones, but any unfilled columns in the new csv will keep the data from the old entry. Hope this makes some sense!

SO, I think the csv import will either create new items, or amend current ones (depending on the sku), and keep old entries if the new csv has no data for that particular column.

I think the best bet would be to delete all products and import the csv again, this should get rid of the duplicate images.

Rick

 
Magento Community Magento Community
Magento Community
Magento Community
 
ezekielf
Jr. Member
 
Avatar
Total Posts:  17
Joined:  2009-03-29
Burlington, VT
 
rickygri - 24 June 2009 03:12 AM

Did you follow step 3 to change the exclude rule? -

3. In “app/code/core/Mage/Catalog/Model/product.php”, on (or near) line 759 change:

public function addImageToMediaGallery($file$mediaAttribute=null$move=false$exclude=true)

to:

public function addImageToMediaGallery($file$mediaAttribute=null$move=false$exclude=false)

+

I’ve reported this as a bug: http://www.magentocommerce.com/bug-tracking/issue?issue=7258 Issue #16307

Zeke

 
Magento Community Magento Community
Magento Community
Magento Community
 
kylewhat
Member
 
Total Posts:  45
Joined:  2008-06-02
 

changing the public function addImageToMediaGallery($file, $mediaAttribute=null, $move=false, $exclude=true) to $exclude=false makes mine not import the images.  when it was $exlude=true it imported the images but excluded them.

also the image label won’t import.

 
Magento Community Magento Community
Magento Community
Magento Community
 
fuzzybabybunny
Member
 
Total Posts:  46
Joined:  2009-08-08
 

I just can’t get it to work right, and I’ve even tried to keep it as simple as possible.

Got a list of 150 products.

In the CVS file I’ve got:
image: /image1.jpg
small_image: /image1.jpg
thumbnail: /image1.jpg

I then take image1.jpg and move it into my media/import folder (since I use Nexcess hosting the full path is /mystorename/html/media/import)

Since I already had all my products in the database already I simply edited my existing CVS file to include the /image1.jpg in the previously blank image, small_image, thumbnail columns.

Imported this file. No images showed up. No images moved to corresponding media/catalog/product folder.

I then got frustrated and selected ALL my products in Magento Admin and deleted them ALL. I also delete all the folders under media/catalog/product

I re-import the exact same CVS file from before using the exact same settings. This time images magically appear, but a great number of products have multiple images (a sofa will have an image of the sofa + image of a bed). Oh yeah, and the Exclude thing is checked. The Sofa image is only selected as the Base Image and the bed image is ticked as small and thumbnail.

I mean, where does Magento magically come up with these settings? Any help would be appreciated.

 
Magento Community Magento Community
Magento Community
Magento Community
 
g0ldstein
Member
 
Total Posts:  36
Joined:  2009-02-15
 

I can’t get more view pictures either ... . help :(

 
Magento Community Magento Community
Magento Community
Magento Community
 
nasha
Sr. Member
 
Avatar
Total Posts:  138
Joined:  2009-04-15
 

Hi
i,m using magento 1.3.2.2 and i used this code to uncheck “Exclude” property.

$product->addImageToMediaGallery(Mage::getBaseDir(’media’).DS .’import’.$file, $fields, false ,false);

 
Magento Community Magento Community
Magento Community
Magento Community
 
jagerstore
Jr. Member
 
Total Posts:  1
Joined:  2009-10-02
 

help!!!!!!!!!!!!!!!!!,

I am setting up a magento 1.3.2.4 site with approx 2000 products, i am importing the products via a csv (excel). The import works great, all the products are there, and also all the atributes. My products are shoes so i have size 3,4,5 etc.... great.

I have all the images on my laptop, so i have upload them to the media/import file on the server, and i know they are all there.

Heres the problem, about 35% of the images are not showing on the frontend or the backend, obviously the other 65% show just fine, no problems. It is as if Dataflow is just disregarding them.

All images paths in the csv have a slash in front of them

I have checked that the filename of the images matches exactly to the path, its not that.

I read that you should not use uppercase in your filename or csv’s but i have alot of images called i.e 8220-R.jpg and these are showing fine.

If I go into each product afterwards and find the file and upoad it, it shows fine.

As this is a “some images” show and some don’t problem, i am tearing my hair out to fix, i do not want to have to go through 2000 products to “fix it”

Please can someone reply with the perfect fix

Many Thx

 
Magento Community Magento Community
Magento Community
Magento Community
 
Bogislaw
Member
 
Total Posts:  63
Joined:  2009-07-29
 

About the “Exclude” - checkbox:

Can’t go into detail here, but:

- Magento 1.4.0.0
- imported images for attributes “image”, “small_image”, and “thumbnail”
- imported whole CSV into an empty catalog

--> All “Exclude” checkboxes are checked, BUT all images are showing on frontend

 
Magento Community Magento Community
Magento Community
Magento Community
 
StevenDiz
Jr. Member
 
Avatar
Total Posts:  2
Joined:  2010-06-16
 

Hello everyone!

I think I may have found a solution to the bizarre image import issues many of us have had. Like many people here, I had gotten image import to work, but only sporadically. Some images would import, while others would not. There didn’t seem to be any logic or pattern to it at all. The same image would even import for some products, but not for others. (My client’s site uses the same image over and over for product “types” rather than one image per product.)

So, I did some digging and it turns out that when my client was sending me data to import, he was not trimming all the spaces/whitespace from the ends of the image names. I was then passing all this whitespace along to the Magento import routine. Amazingly enough, it turns out that the image import does NOT trim whitespace from the ends of file names. So, instead of trying to import, “image1.jpg” it was looking for “image1.jpg “. (Note that there should be multiple spaces there. But your browser probably collapsed it to just 1.)

The solution is pretty simple, just trim all of the image names before you include them in your import CSV file.

If you don’t mind mucking around inside the guts of Magento however, all you have to do is change the addImageToMediaGallery method to trim any whitespace off of the file name that it is passed.

In my copy of Magento, it’s in the file /var/www/magento/app/code/core/Mage/Catalog/Model/Product.php. The line you want to change is this one:

$mediaGalleryAttribute->getBackend()->addImage($this$file$mediaAttribute$move$exclude);

Change it to this:

$mediaGalleryAttribute->getBackend()->addImage($thistrim$file), $mediaAttribute$move$exclude);

That’s it! The file name that’s passed will now be stripped of whitespace and your images should be added much more reliably.

(Note that this is a change to the Magento Core. I’ve not had a chance to work out how to override this method yet [I’m very new to Magento], so if anyone would like to pass that info along, that would be great.)

Hope this helps!

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