Jump to content

SQL query to add images


madalin
 Share

Recommended Posts

Hello,

I am trying to insert products using custom SQL queries. So far so good, but the problem seems to be when adding the images. I already have all the images and i can link them to the products. However, how would i go having the image automatically be resized and such ?

What would be the query ? Thank you.

Share this post


Link to post
Share on other sites

Bump. Anyone ?

Let me explain further. I have the images uploaded in my folder and i can link them to each product. What query should i INSERT into the db so that the image gets placed automatically to the product ? I can see the `image` atribute exists in lots of places in the db but nowhere i can see the PATH of the image..

PLEASE ?

Share this post


Link to post
Share on other sites

You're thinking about it the wrong way. PrestaShop doesn't store the path to the images for each product in the database. It renames all the images using the product ID and image ID to associate them. The only thing you need to do is make sure that the image names match the IDs in the ps_image table. For example, if the product ID is 6 and the image ID is 8, then you should name the full-size image "6-8.jpg", then resize the images into files with the image size after the name. For example, for the 'home' size, name the image "6-8-home.jpg".

Share this post


Link to post
Share on other sites

You can generate the image ID yourself. For example, the first image you ever added to your shop has image ID 1, then the next ID 2, etc. You need to insert these into the ps_image table if they aren't already there. It is easiest to just create a product CSV file with links to the images and go to Tools > Import and import the CSV so that PrestaShop does all this for you.

Share this post


Link to post
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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More