Jump to content

Is the webservice right tool for adding a new product


down999

Recommended Posts

Hi, please I have a question.

I thought that the webservice is right tool for adding a new product. I'm making a php script for that, and I think something else right now. I don't know if is the right way.

 

I am creating the new product with the images, but I don't know his new ID. So, I must do this steps:

- 1.: Send the new product

- 2.: After sent, I get the new ID of the new product

- 3.: Then (when I have a ID of the product), I post the pictures (with the curl

- 4.: After sent, I get the ID of the pictures

- 5.: Then, I edit the product, because I need to add the ID of the default image,

 

Here is too much connections, and too much coding.

 

Am I doing something wrong. Is there more easily way how to add the new product with all features (like images, combinations, product features...)?

 

Is here somebody who could gave me some direction, tips for some better tools, or other knowledge?

 

Thank you very much!!!

Link to comment
Share on other sites

you would typically add a product from within the back office | Catalog section. Select the category or create a new category, and then click the add button to create a new product.

 

unless you are truly trying to automate the process?

Link to comment
Share on other sites

Thank you for the answer.

No, I want do it by script.

Yes, to automate the process.

So, I using the REST webservice for that. http://doc.prestashop.com/display/PS14/Using+the+REST+webservice

 

I'm on the half way with my script, but I don't know if I lost too much time with that. Because, as I wrote, I must do too much steps for adding the product with all features. And I'm looking for more easy way.

You know, for example if is possible to add the product with the image by the REST webservice in the one step (not in the 5 steps how I wrote in my first post).

Or some documentation where I can find more informations about that.

 

Thanks again!

Link to comment
Share on other sites

I think the webservice is not full of options (not complete) because I have the same problem using it. And I had just read some posts on the forum and it seems people have to do same as you.

It is a lot to do, but it is only done once, when new products are added to the database.

 

(Forgot my mistakes during writting english)

Link to comment
Share on other sites

  • 7 months later...

i'm working on a import script in prestashop, using webservices, i've done also another script which directly insert things in the database, i can say this:

 

the straight forward script (done in php and with image resize/copy) takes about 5 minutes to import about 10 categories, 300 products with an image each, and with at least 5 combinations

 

on the other hand, now i'm using PS 1.5 and the webservices, to import the same amount of data it takes longer than half an hour....with all the things that this time concernes... like timeouts and so on, the advice is:

 

MAKE IT BY YOURSELF.

 

the tables to work on aren't so much...and with some research you will be able to uopdate them easily

Link to comment
Share on other sites

Thanks for the additional info "Intra". However I am on ver 1.4.9 and none of the "Image_xx" provides a directory path.

There appears to be some type of linked list scheme between the tables, but I do not understand it :(

Since 1.5, there is also ps_product_shop table

 

Images are linked with products in ps_image table, with id_image you can find the dir path. (a simple cut)

ex: id_image : 1463 / path : /img/p/1/4/6/3/1463.jpg

 

Just get an eye into the images directory (/img/p/ for products), watch the path of a product image, and you will see the path is the id of the image, same id from the table ps_image.

Link to comment
Share on other sites

The database does not contain a path name. Product Images are always stored under /img/p

There are 2 different image file systems for products.

1. Legacy. All product images are store under /img/p using the id_image (from ps_image table). If the image id is 1463, then the main image will be named /img/p/1463.jpg

2. New system. All product images are stored as Intra describes using subfolders for each number in the id_image /img/p/1/4/6/3/1463.jpg

 

So you will first need to decide which image file system the site is using, and then program that into your script. If this is a one time load of products, then I would switch to legacy file system, load all images to /img/p and then use the back office function to move the images to the new file system layout.

  • Like 1
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...