Jump to content

Importing pictures not working with CSV file


Recommended Posts

I have the URL correct, as I can click the link and see the photo, but when I put a link in a CSV file to import I always get the message "Error copying image: http://www.mydomain.com/image.jpg". Obviously this is along with the product details.

 

As I say, if I click the same link it goes to the picture fine, so I know it is there. Any ideas why it is happening ? I have made sure Prestashop sees the correct column as Image URL while importing. I have tried both a folder I made and the P folder. I have changed to 777 for permissions. I have tried a few different images.

 

Anything else I can try ? Thanks.

Link to comment
Share on other sites

Same problem here, I tried using the Legacy File system, tried recursively chmodding all directories to 777 (/img), nothing seems to work. Also changed the code (controllers/admin/AdminImportController.php) as explained in the link above, but this doesn't help either.

 

Switched form server (perhaps an error on the server settings), but nothing seems to work.

 

Anybody with a solution for this yet? Downgrading to 1.5.2 seems the best way to go, with several thousands of images to upload...?

Link to comment
Share on other sites

  • 2 weeks later...

This looks like it might do the job https://github.com/P...0e3ebe473233d07

 

Just tested this and can confirm it works for me :-)

 

That fix kind of worked. I got one step closer and managed to return an error "Product n°1: the picture cannot be saved:"

 

Not sure what that is about now. It is defo a bug that needs to be fixed! Its not quick to manually input thousands of products.

Link to comment
Share on other sites

  • 4 weeks later...
  • 2 weeks later...

I also had this problem and resolved it by modifying two lines of code in the /controllers/admin/AdminImportController.php file.

 

The changes I made for this to work are on line 647 and 650.

 

Line 647 reads:-

 

$fd = fopen($temp, 'r');

 

Change to:-

$fd = fopen(_PS_UPLOAD_DIR_.$uniqid, 'r');

 

Line 650 reads:-

 

unlink($tmp_file);

 

Change to:-

unlink(_PS_UPLOAD_DIR_.$uniqid);

 

Hope this helps anyone who is trying to resolve this until it gets fixed by PS :)

Link to comment
Share on other sites

  • 4 weeks later...
  • 1 month later...

This is probably a stupid question, but how do I replace the broken code? When I replaced the AdminImportController file a while ago I did it by just taking out a whole file and replacing it. I have tried moving parts of the code from Github into the right place in the prestashop files, but I couldn't get it right. I really don't know anything about coding.

 

I do think I could swap out a broken whole file for a good one. Would someone please post a link to a file of the fix https://github.com/PrestaShop/PrestaShop/commit/8d7196daf3b39d280c631882f0e3ebe473233d07

or explain how to fix it using just the lines of code up on Github.

 

either way, help is appreciated!

Link to comment
Share on other sites

Hi preserver,

 

I hope you're a bit skilled in German language for this could help you to understand the solutions I posted here and an override file I posted here: http://www.prestasho...ost__p__1134485

 

 

 

Important: Rename the override file to AdminImportController.php first and then copy the file to directory /override/controllers/admin.

 

Users of 1.5.4 should upgrade to 1.5.4.1 which contains a fixed controller.

  • Like 1
Link to comment
Share on other sites

Eleazar, thanks so much for your response! Though I did take a year of German, I had to rely on Google's translation for help... :) I did look at the forum chain you referred to about 1.5.3 bugs, but I wasn't entirely sure where the file was that got everything worked out...

 

I tried uploading your AdminImportController file as a php, but I can't figure out how to save it as a php file, not a txt. How do i do it?

 

Let me see if I understand how the bug fixing works: When there is a bug to be fixed, can I take the code from Github, save it as a php file (not sure how to do this yet) then upload it to directory/override/controllers/admin? In general I'm guessing there are two ways of fixing a bug- replace the whole file at its original location or place a file with just the lines to be corrected in the appropriate directory within 'override'. Is that right?

 

I know I still have an original version of the AdminImportController along with a corrected one saved alongside one another in the directory/controllers: the old one as AdminImportColler-BACKUP.php, the new as AdminImportController.php. Is that right? I had meant to delete the old 'backup' version, but i didn't think it was causing any problems... Should delete the original one? Maybe

 

Also, is it preferable to just switch from 1.5.3.1 to version 1.5.4.1, or will it be hard to get a theme that works for a newer version? I don't have a lot customized yet on my shop, so I don't mind redoing what I have selected and uploaded. If a newer version will have fewer other bugs or problems I would definitely prefer that!

 

Thanks for all the help! :) It is VERY much appreciated.

 

Helen

  • Like 1
Link to comment
Share on other sites

Hi Helen,

 

don't apologize! I'd be the last person to blame anybody for missing language skills in German. Like Mark Twain once said, 'It is easier for a cannibal to enter the Kingdom of Heaven through the eye of a rich man's needle that it is for any other foreigner to read the terrible German script.' ;) ... and never ever trust Google's translations. They are sometimes godawful.

No, seriously, an override requires a special syntax which means you cannnot just copy a 'normal' PHP to an override directory.

 

In general I'm guessing there are two ways of fixing a bug- replace the whole file at its original location or place a file with just the lines to be corrected in the appropriate directory within 'override'. Is that right?

 

Correct, but it depends on how you do it. Overrides start with e.g.

 

class AdminImportController extends AdminImportControllerCore

 

whereas the controller code you want to override starts with

class AdminImportControllerCore extends AdminController

 

You see the difference?

 

The override I uploaded has an additional '.txt' suffix because the forum restrictions don't allow the upload of php files. You just have to rename the file by skipping this '.txt'. That's all.

 

And yes, it makes sense to upgrade to 1.5.3.1, but upgrading to 1.5.4.1 depends on how your theme and addons are already adapted to 1.5.4.x. As 1.5.4 comes along with a lot of modified core it may happen that you would cause trouble.

 

Thx for the appreciation.You're welcome. :)

 

Regards,

Rainer

Edited by eleazar (see edit history)
  • Like 1
Link to comment
Share on other sites

I'm not sure what I had been doing to mess up saving the fix as a php file, but this time everything fell into place. Voila, csv loaded product images work! It seems like a small miracle!

 

I don't think I understand your explanation about the overrides very well though...

 

I will have to pass word about this fix on to someone else who was having the issue.

 

Such a small world- Texan using French software, receiving help from an Italian and a German. Then sending word of help to an Englishman. :P

Link to comment
Share on other sites

  • 4 months later...

I'm sorry, but since PrestaShop's forum software was updated last month I don't receive notifications from foreign forums any longer - one of the many bugs not yet solved.

 

Looked into your CSV file.

 

First of all: You don't have to mention every possible item if it's not necessary for import.

If you would have dropped all field names with no entries, you would have realized easily that the mapping in your file isn't correct. E.g. the img URLs are mapped to "Condition (new,used,refurbished)", while the field "Image URLs (x,y,z,...)" is empty.

Just import not empty fields and when asked in the mapping window for fields not in your import file, choose 'ignore this item'.

 

Never use a full URL like 'http://www.hortus.com.pl/allegro/dek020.jpg', because this doesn't match the real direcotry structure of your server. Just use a relative url. E.g. if the pictures are in a subdirectory 'allegro' of your root, then the correct url should be 

../allegro/dek020.jpg

And to avoid double entries in your database you have to activate either the option to delete all data entries before import or, if you dont' want this to happen, the other option to overwrite existing products. But then you MUST include the ID in the first field, like it is in the database products table.

 

Hope this is helpful for you.

Link to comment
Share on other sites

I am on ver 1.5.3.1. I have applied the Adminimportcontroller fix and it did fix a problem I was having with categories, but I still can't get my images to work. The import process doesn't generate any errors or warnings. Then when I view the web site the only image that will appear is the one associated with the very first product I loaded. All other products act like an image is there but nothing actually appears. Is any one else seeing a similiar problem, this is very fustrating consumming many hours. Thanks.

Link to comment
Share on other sites

Thanks for the reply. I have my images in a directory /home/dogwood1/images. The directory has perms of 777 and the images all have perms of 644. Here are the first 3 lines of my csv:

 

"Prodids";"Enabled";"Name";"Categories";"Price";"Tax rule ID";"Buying price";"On sale";"Reference";"Weight";"Quantity";"Short desc";"Long desc";"Images URL"
0001;1;"48-203";Home,12;7;;4.80;0;"48-203";"0";   10;"TROPICANA BOXCAR 60 FT        ";"TROPICANA BOXCAR 60 FT";"../../images/48-203.jpg"
0002;1;"48-29";Home,12;7;;4.80;0;"48-29";"0";    1;"PFE REEFER CARS R-40-23 CLASS ";"PFE REEFER CARS R-40-23 CLASS 2 SHEET SET (1946-1952)";"../../images/48-29.jpg"
0003;1;"48-552";Home,12;7;;4.80;0;"48-552";"0";    1;"SINCLAIR SERVICE STATION      ";"SINCLAIR SERVICE STATION (1935-1960)";"../../images/48-552.jpg"
0004;1;

 

The upload behaves (no errors) like the images are processed, but afterwards only the first product has an actual image. The other products just have the product id number as their image and it can't be deleted.

Link to comment
Share on other sites

The other products just have the product id number as their image and it can't be deleted.

 

This makes me suspect that your mapping of the fiels during the import process is not correct. Do you really

  • skip the first line ...
  • choose ISO-8859-1 (if not utf-8 coded) ...
  • map the images urls to table field 'images url' before you click the start button ...

... before you press the start button for import?

Link to comment
Share on other sites

I still can not get past this problem. I have confirmed that my fields are properly mapped and I am skipping the first line and that the encoding option is checked. I also blew away my prestashop installation and reinstalled fresh. I then applied the adminimportcontroller fix, which corrects the assignment of categories to products. I have safe_mode = off and allow_url_fopen = true in my php.ini file. After all this, I still only get the image loaded for the first product in my csv file. The remaining products show image files associated with them, but they are just ordinal numbers (2,3,4,etc) and they can't be deleted. I can load images manually for the products after the import, but this will not be feaseable for over 1000 products.

 

csv file:

"Prodids";"Enabled";"Name";"Categories";"Price";"Tax rule ID";"Buying price";"On sale";"Reference";"Weight";"Quantity";"Short desc";"Long desc";"Images URL"
0001;1;"48-203";Home,O Scale Decals;7;;4.80;0;"48-203";"0";   10;"TROPICANA BOXCAR 60 FT        ";"TROPICANA BOXCAR 60 FT";../../../images/48-203.jpg
0002;1;"48-29";Home,O Scale Decals;7;;4.80;0;"48-29";"0";    1;"PFE REEFER CARS R-40-23 CLASS ";"PFE REEFER CARS R-40-23 CLASS 2 SHEET SET (1946-1952)";../../../images/48-29.jpg
 

Link to comment
Share on other sites

  • 1 month later...

Yea same exact problem here, attmepted to use the adminimportcontroller.php that was uploaded and it will not load the import page, i had to revert to the old semi working better one. IM USING 1.5.4.1  and this is driving me insane. I have spent hours here messing with code (tried both github solutions) Im really just about ready to give up on this cart and move on....... really nice this continues to go and and the moderators havent responded to this post <_>

Edited by OneStopPipeShop.com (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...