Jump to content

Importing Images


Recommended Posts

Hi,

I have managed to figure out how to import Categories, sub categories, products and attributes, but I am having a real nightmare with importing images.

Here is my csv file, can anuone please have a look and see what I am doing wrong, as it is driving me crazy.

I really appreciate your help

Kind regards

Jarno
SpikeDM

ProductTemplate.csv

Link to comment
Share on other sites

Sorry to ride on this thread as I am facing the same problem (do not wish to start another thread on this).

I have been at it for 2 days already !!
I can import anything from categories to products to manufacturers but I, too cannot get images to import !!

I read all the threats already and tried everything but images just will not import.

I am using Version 1.1.0.5 - 0.033s.

do you think "allow_url_fopen" will make a difference in this ? because my service provider will not allow this.

Thanks in advance for your have.

Rog

Link to comment
Share on other sites


do you think "allow_url_fopen" will make a difference in this ? because my service provider will not allow this.


Yes, it makes a very big difference. Something that none of the prestashop documentation seems to mention. I also spent several days trying to figure this one out. I a handy reminder on the import page which detects the settings would be a life saver for many people.

If you do not have allow_url_fopen enabled (and it's one of those settings that can't be overridden with ini_set() or .htaccess) then you will *not* be able to import images from a URL even though it will say the import was successful. It will even seem like it imported an image because the "View full size" option shows up in listings.

You *can* however, import images if they're stored locally. for the Image URLs (x,y,z...) field just use a relative or absolute path to your image. (i.e, /var/www/localhost/uploads or C:\pics et cetera). Just make sure the user your web server runs under has read access to the images!
Link to comment
Share on other sites

Thank you for your reply.

You are correct and thanks for pointing this out !!

To test I used the attached csv file under WAMP.
I went to WAMP and disabled the "allow url_fopen".

And right away products ID 21 and 22 images could not load (file on remoted URL).
ID 20 and 23 loaded ok (file on local hdd) and I can see these images within the products on the WAMP server.

But when I uploaded the same file to the ISP server and started import, I was expecting products ID 20 and 23 to load.
However all 4 products came out without pictures (including ID 20 and 23).

Which makes me think about your comment below :

"Just make sure the user your web server runs under has read access to the images!"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

in Test environment (WAMP) I have access to both the WAMP and also the C:\temp\eight.jpg
so I suppose that's why products ID 20 and 23 came up ok within and updated in WAMP server.

But my site is hosted with my ISP and importing using the prastashop backend "import", so any other setting I have to do in order to make this work ?

Thanks in advance for your help !!

Rog

Products.csv

Link to comment
Share on other sites

Since prestashop creates the various sizes/thumbnails during the import and leaves the original image alone a simple method is to:

1. (s)ftp to your hosting provider
2. Create a new folder
3. chmod it 755 (owner read+write+execute, group read+execute, other read+execute)
4. Upload product images to new folder
5. Modify csv file to point to new folder (if you don't know the full path use a relative path from the admin directory. So if your cart and the new folder are at the root of your site you could use something like: ../prodimgs/red_hat.jpg)
6. After import completes delete the entire folder. (prestashop would have created the versions it needs in img/p so the folder is just taking up space now)

I hope this solves your problem.

For everyone reading this thread, remember local folder means local to the server *not* the user running the import. If you're putting C:\xxx.img because that's where the file(s) is/are locally to you, the server at some some datacenter in AZ won't be able to upload the file(s).

This coupled with remembering to use the product ID in your CSV, until the next release where that bug has been fixed, should solve any and all conceivable image related import issues.

Remember you can specify multiple images (different views perhaps) by separating them with commas, just make sure if you're editing your CSV by hand (for some reason) that they need to be enclosed in double quotation marks: "../prodimgs/front.jpg,../prodimgs/back.jpg,../prodimgs/side.jpg" for example. The image you display first will be the "default" or "product cover" in prestashop speak.

I think that should cover every image related issue I've come across...

Link to comment
Share on other sites

Hi there,
Think that this is the same problem i related in this post about images on community servers : http://www.prestashop.com/forums/viewthread/16355/P0/rapports_de_bugs/bug__import_csv_avec_images__serveur_mutualises
Isn't it ?
May be mass votes would decide prestateam to correct the import processing or a php developer to built a performing module for importing products with images ...

Link to comment
Share on other sites

i am facing soo much trouble with this.

Firstly to remove any doubts i am using 1.1 and have a copy or 1.2.0.1 so i am trying with both.
I am importing 3 products to test it (so no i am not importing 500 and not getting timed out error)

After the import, i look at the /img/p (no images there)
in the /img/tmp, i get 3 new files , something like this:
/img/tmp/ps_import8kvyyZ
/img/tmp/ps_importmjaTi7
/img/tmp/ps_importoVPZmd
with permissions 600
owner is nobody (which is the httpd user)

Since these files are being generated in the tmp folder, i assume the image path in the csv is right and the product upload folder is set to 777 (being read and files are taken from it)

Why are these files getting stuck in the tmp????

Link to comment
Share on other sites


Why are these files getting stuck in the tmp????


The first thing that comes to mind is that the folder permissions for img/p/ aren't correct. If it's pulling images and making temp images but they aren't making it into the final folder the server might not have write perms to the img/p/ folder. You'll also have to have execute perms because it's a folder. You don't need read perms to create the images... but you will to display them.

So. to recap you need all perms (read+write+execute [7]) for the server's user for the img/p/ folder in order to create and view the images. You probably want to play it safe and just make sure the user has those perms for all the img/ folders while you're at it.

Also, remember, just because the server itself runs as say apache/wwwuser/nobody, on shared host they'll often do a setuid (using suEXEC for example) on the process for your virtual host to give it an effective UID of your account.
Link to comment
Share on other sites

Hi there,
Think that this is the same problem i related in this post about images on community servers : http://www.prestashop.com/forums/viewthread/16355/P0/rapports_de_bugs/bug__import_csv_avec_images__serveur_mutualises
Isn't it ?
May be mass votes would decide prestateam to correct the import processing or a php developer to built a performing module for importing products with images ...


could be... I can't read French :P There's no doubt though that some changes need to be made to the import tools, particularly with regards to images. (And categories while I'm on the subject, but I digress...) Don't get me wrong, it's probably the best FLOSS solution I've come across... it could just use some polishing.
Link to comment
Share on other sites

tulkastaldo,

Thanks alot for trying to help me and others out.

The permissions of the /img forlder and the subforlders are 777 are you can see in the snapshots below.
You can see in the first screenshot the user and groups and permissions of all the directories inside the /img
in the second screen shot the files that are created and getting stuck in the tmp directory with the 99 as owner and group and permissions 600.

Yes, it is shared hosting, and after asking the provider and battling with them to install phpsuexec, they did for installed and said that they reverted back (uninstalled it) right away as it messed all the rest of their customers up.

So, I dont know what i need to do, or what they need to do, that is why i dont know what would make this image import work.
If you can further help out would be really great and i would be more than happy to provide you the info needed in order to troubleshoot this.

6984_XqiZRhB0HHJCeaKGPFHj_t

6985_5Lytbce5Z3AXrs0gnQY5_t

Link to comment
Share on other sites

hmmm... Ok. Then the second thing that comes to mind is: do you have GD support?

When it makes the thumbs et al it uses GD functions (specifically imageResize()) which makes the new files so it's not copying the old file anywhere. The only time it uses copy is to bring the file into the tmp dir, which we already know works fine.

you can check for GD support with a simple info page

<?php
phpinfo();
?>



just create a php file with that, upload and browse to it. You'll get a big listing of what's supported and a bunch of general and server information. If you scroll down about.. 1/2 way (your millage may very depending on what's enabled or not) you should see something like what's in the screen shot. If it is enabled, make sure support for the image file type you're trying to import is enabled.

If GD isn't enabled you'll need to talk to your hosting provider to see if you can get it installed.

If it definitely *is* installed and all the support you need is enabled see if you can get the tail of your error log it should be griping about *something* which should give you a good idea of where the issue lies. If you have cpanel support you should be able to find it buried in there some where. webmin can have logs, but with the granular level of control providers have over it you may or may not find it. Some provides will create an error_log file in the folder that the script is running from (check your admin dir/tabs) Usually shared hosting will create independent logs for each user, but if that's not the case you may have to ask the admin for help. Be sure to give the closest timestamp possible of when you run the script, and even then he may not be able to track it down.

6993_nNhFcBGimFuotv7a29VR_t

Link to comment
Share on other sites

In the attached picture you can see my GD config, i am trying to import jpg as file type/format.
Our GD setup nearly identical.

I looked everywhere for logs and spoke to the hoting guy twice, thye were monitoring logs while i ran the script, yes the GD is not writing any log, they looked at my user logs and the nobody logs.

Questions here as i am trying to think outloud:
-Since I can add images manually from the product page, and they get generated and they show pictures in the front office fine, would not that mean that GD is working fine?
-it is just the import pictures that does not work
-from what I and the hosting guy noticed, that the images generated when i add an image from the product page, they have 644 permissions and owner nobody, however when I use the import, i get these weird 0kb files with 600 permissions and owner nobody.

a)If we make the import to write as 644 would that make it work?
b)how can i make it write them with cerrtain permissions , do i have control on that?

thanks mate

7001_7DU0Ryvg0knKodGlabn8_t

Link to comment
Share on other sites

however when I use the import, i get these weird 0kb files with 600 permissions and owner nobody.

a)If we make the import to write as 644 would that make it work?
b)how can i make it write them with cerrtain permissions , do i have control on that?

thanks mate


Forgive me. I completely overlooked the 0kb filesize when I first looked at your pictures. This is what I get for posting at 3am after battling my own presta issues. ;)

0kb clearly indicates it was unable to read the source image. You may have your path wrong or... the folder with the images is 777 but the images themselves are unreadable. I would double check the path and then check the perms of the images you're trying to copy from, go ahead and 777 them too since you'll just be getting rid of them after the import anyway. If you use a completely bogus path such as /obviously/fake/img.jpg for your image column it will create exactly what you're seeing.

Taken from my server using a fake path:
-rw------- 1 apache apache    0 Apr 21 23:55 ps_importHk7tvj



Incidentally the tmp images having those perms wouldn't be a problem. Since we know the process creating them will be the same one reading them back the user would be the same and user has read and write perms which is actually more access than it needs.

As an academic exercise, you could theoretically change the perms on the created files, but it's not a setting you would find in the back office, you would need to modify the code. Also since the line to create the tmp image is just

if (@copy($url, $tmpfile))


you'd have to chmod it after the fact, you can't make it write the file with particular permissions without trapping the mask, setting a new one, then resetting it afterwards and using umask() on threaded servers is strongly discouraged.

Link to comment
Share on other sites

Thank you soooo much for trying to help me further.

Regarding the pictures folder permissions are set to 777 all the time (i dont mind)
here is what I did just minutes ago:
Changed the paths and tried different ones:

/home/domain/public_html/test1/p/p100.jpg results with the files 0kb 600 permission
'/home/domain/public_html/test1/p/p100.jpg' results with the files 0kb 600 permission
"/home/domain/public_html/test1/p/p100.jpg" results with the files 0kb 600 permission
/public_html/test1/p/p100.jpg results with the files 0kb 600 permission
'/public_html/test1/p/p100.jpg' results with the files 0kb 600 permission
"/public_html/test1/p/p100.jpg" results with the files 0kb 600 permission

then tried
http://domain/test1/p/p100.jpg (which is an image that will open in my browser) results with nothing been generated anywhere,
"http://domain/test1/p/p100.jpg" (which is an image that will open in my browser) results with nothing been generated anywhere,

'http://domain/test1/p/p100.jpg' (which is an image that will open in my browser) results with the files 0kb 600 permission

Link to comment
Share on other sites

tulkastaldo, I just wanted to say "thank you" so much for helping me out in my earlier question.
now it's fine and I can do the csv img thingy.

I can login to this board but for some reason my ISP at home and office I cannot post msg here.
now that I found a way to post (using another ISP), I have to remember to thank you !

Rog

Link to comment
Share on other sites

Thank you soooo much for trying to help me further.

Regarding the pictures folder permissions are set to 777 all the time (i dont mind)
permission


If you read carefully my main point was that even if the folder is 777 the image files themselves may not be readable.

Remember from the earlier posts that the http:// urls won't work if you don't have allow_url_fopen enabled.

It really sounds like a permissions problem to me, but without access to your environment it's hard to pinpoint where the problem lies.
Link to comment
Share on other sites

Hello,

been away from the email address that I registered with PresatShop and only just got an email that there had been some posts to the original post I did.

After much head scratching and messing about, I found out why my images were not uploading from the products.csv I was uploading.

It was simply todo with the fact that my products in the product.csv were not in numerical order.

I had to put "product ID 1" first and then 2,3,4....etc.

This then worked fine for me.

Hope this helps others with the same problem?

Not sure what will happen tho if I have just one product to upload that starts with 15 or 45 etc??

Link to comment
Share on other sites

  • 3 weeks later...

hello,
does anybody know which table in the database should be update with the information of imported images?

if i'm not able to upload images via CSV images, i thought it would be easier to insert URLs or paths into the database.

thanks in advance

Link to comment
Share on other sites

I dont think it is that simple. the script generates different images and sizes out of one image.

I still did not manage to get the image import working, actually i gave up and went and done it manually. it is less time then research and fixing as i spent a week trying to troubleshoot it.
good luck

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...