rem101 Posted October 18, 2008 Share Posted October 18, 2008 Hi, I have some experience php and I have a good amount with MySQL. I have imported all of the data in the shop, its a little over 3000 items. Can someone tell me what functions are used in the code to do the image manipulation and upload? I looked at it, and I'm not really sure how the images get resized and uploaded. I'd like to be able to upload all of the images and update the db. I can get the names of the images from the database as they are part of the manufacturer's part number and I have shell access. Any help would be appreciated.Thanks,Rob Link to comment Share on other sites More sharing options...
Son Ame Posted October 20, 2008 Share Posted October 20, 2008 pls tell how did u import all 3000 items? Link to comment Share on other sites More sharing options...
rmcmonigal Posted October 21, 2008 Share Posted October 21, 2008 I created a text file with the items seperated by @'s. Then I created the categories that I was going to use, and added the category id's into a new column in the file (the category id's have to be seperated by commas.) So a line out of my import file would be something like00001@3D Dragon Cue@A great cue stick for any level of [email protected]@200.00@4,6,9the fields for this are as follows:wholesaler idnamedescriptionwholesale priceretial pricecategories (their id's)I had to break the file into smaller files consisting of 300 records each, and I imported them under tools | import. After the import I choose the columns. Since I didn't have a wholesale price column I just choose another column to put the data in. One note, you have to escape single and double quotes, registerd and copyright symbols and angle's <>. I used the html equivilents (I replaced all of the "" with "). Hope that helps.Thanks,Robhttp://www.cheapcharliesbilliards.com Link to comment Share on other sites More sharing options...
rem101 Posted October 26, 2008 Author Share Posted October 26, 2008 I figured out how to upload the images at once, but I need to say that this isn't a task for someone who isn't a programmer. Please read all of the steps before starting to make sure you can complete this.1) Backup the database -- don't continue, if you do not have a means to do this.2) insert an image record into the ps_image table for all products that do not have images, I am only concerned about english, which is why I have id_lang = 1. To do this run this against the database:insert into ps_image (id_product, position, cover)SELECT id_product, 1 as position, 1 as coverFROM ps_product_langWHERE id_product NOT IN (SELECT id_productFROM ps_image)AND id_lang =13) insert a description in the correct language in the ps_image_lang table, once again, I only use english on my site, Here's the query:insert into ps_image_lang (id_image, id_lang, legend)SELECT ps_image.id_image, 1 as id_lang, SUBSTRING(ps_product_lang.name,1, 63) as legendFROM ps_product_langJOIN ps_image on ps_image.id_product = ps_product_lang.id_productWHERE ps_image.id_image NOTIN (SELECT id_imageFROM ps_image_lang)AND id_lang =14) At this point the image records have been created and you need to copy all of the images to the p directory under the img directory of the shop root directory. So, if you installed prestashop under /usr/local/apache2/presta, the directory would be /usr/local/apache2/presta/img/p/. They also have to be named id_product-id_image.jpg. I'm not sure if they have to jpg's or not, mine were so and it worked. My wholesalers name the images their part number, which I have as the supplier reference number in prestashop. To get all the id_product, id_image, and supplier_reference data I ran:select ps_image.id_product, ps_image.id_image, ps_product.supplier_referencefrom ps_imagejoin ps_product on ps_product.id_product = ps_image.id_productand stored the results in a semi-colon delimited test file named images.txtThen I copied all of the images, renaming them to the correct name for presta. I did this with a python script, which I modified to make it clearer here:import sysimport os, os.pathimport shutilo = open('images.txt')r = o.readlines()o.close()current_image_dir = '/usr/local/images/'presta_image_dir = '/usr/local/apache2/presta/img/p/'for x in r: xs = x.split(';') current_image = xs[2].strip() + '.jpg' presta_image = xs[0].strip() + '-' + xs[1].strip() + '.jpg' if os.path.exists(current_image_dir + current_image): shutil.copyfile(current_image_dir + current_image, presta_image_dir + presta_image)Once they were all copied over, I recreated all of the thumbnails for presta by going to admin | preferences | images and clicking on the recreate thumbnails buttons. This took a while for 3000 images. I don't remember the exact time, but it was in excess of thirty minutes, and during that time the webpage timed out, but the process continued to work. You need to watch the img/p directory and wait until the new thumbnails are no longer being created. On my machine a new thumbnail was created every second and I waited until a new thumbnail wasn't created in a minutes time.So this worked for me, if you have any questions please feel free to ask.Thanks,Rob 1 Link to comment Share on other sites More sharing options...
tokyoNH Posted October 31, 2008 Share Posted October 31, 2008 This is PERFECT! It is just what I was looking for. I have 20,000 images to upload to go with the products... wasn't looking forward to one at a time!! Link to comment Share on other sites More sharing options...
dragosh_F Posted November 16, 2008 Share Posted November 16, 2008 Images won't upload using CSV import if you don't specify product ID. Just add a diffrent numeric ID to each line of the CSV file and images will be added. If you don't add this ID, pictures will be uploaded and created anyway, but you will see them only by looking into the ftp folder. Also make sure that you have set right folder permissions (if not, you should see an error)Dragos Link to comment Share on other sites More sharing options...
galtechsolutions Posted January 31, 2009 Share Posted January 31, 2009 I figured out how to upload the images at once, but I need to say that this isn't a task for someone who isn't a programmer. Please read all of the steps before starting to make sure you can complete this.1) Backup the database -- don't continue, if you do not have a means to do this.2) insert an image record into the ps_image table for all products that do not have images, I am only concerned about english, which is why I have id_lang = 1. To do this run this against the database:insert into ps_image (id_product, position, cover)SELECT id_product, 1 as position, 1 as coverFROM ps_product_langWHERE id_product NOT IN (SELECT id_productFROM ps_image)AND id_lang =13) insert a description in the correct language in the ps_image_lang table, once again, I only use english on my site, Here's the query:insert into ps_image_lang (id_image, id_lang, legend)SELECT ps_image.id_image, 1 as id_lang, SUBSTRING(ps_product_lang.name,1, 63) as legendFROM ps_product_langJOIN ps_image on ps_image.id_product = ps_product_lang.id_productWHERE ps_image.id_image NOTIN (SELECT id_imageFROM ps_image_lang)AND id_lang =14) At this point the image records have been created and you need to copy all of the images to the p directory under the img directory of the shop root directory. So, if you installed prestashop under /usr/local/apache2/presta, the directory would be /usr/local/apache2/presta/img/p/. They also have to be named id_product-id_image.jpg. I'm not sure if they have to jpg's or not, mine were so and it worked. My wholesalers name the images their part number, which I have as the supplier reference number in prestashop. To get all the id_product, id_image, and supplier_reference data I ran:select ps_image.id_product, ps_image.id_image, ps_product.supplier_referencefrom ps_imagejoin ps_product on ps_product.id_product = ps_image.id_productand stored the results in a semi-colon delimited test file named images.txtThen I copied all of the images, renaming them to the correct name for presta. I did this with a python script, which I modified to make it clearer here:import sysimport os, os.pathimport shutilo = open('images.txt')r = o.readlines()o.close()current_image_dir = '/usr/local/images/'presta_image_dir = '/usr/local/apache2/presta/img/p/'for x in r: xs = x.split(';') current_image = xs[2].strip() + '.jpg' presta_image = xs[0].strip() + '-' + xs[1].strip() + '.jpg' if os.path.exists(current_image_dir + current_image): shutil.copyfile(current_image_dir + current_image, presta_image_dir + presta_image)Once they were all copied over, I recreated all of the thumbnails for presta by going to admin | preferences | images and clicking on the recreate thumbnails buttons. This took a while for 3000 images. I don't remember the exact time, but it was in excess of thirty minutes, and during that time the webpage timed out, but the process continued to work. You need to watch the img/p directory and wait until the new thumbnails are no longer being created. On my machine a new thumbnail was created every second and I waited until a new thumbnail wasn't created in a minutes time.So this worked for me, if you have any questions please feel free to ask.Thanks,Rob I am getting error in second step.This was the error :#1054 - Unknown column 'legend' in 'field list'Please help me.Is there any other method ? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now