Jump to content

Adding stock quantity upon creation of new product via webservice


Recommended Posts

Hello,

 

I'm currently using Prestashop 1.5.4.1 web service to create new products using a 3rd party application i'm developing.

 

I can create products, but i'm having two major issues.

The first one is setting quantity. The recent changes in PS1.5 changed the quantity field from the products table to the stocks table. So if i trie to pass a quantity field in the xml, i get a message telling me i cannot use this field.

So, i have to use associations->stock_availables->stock_available, but i cannot find any documentation anywhere on how can i pass my stock quantity upon creating the new product.

 

Is it event possible to do this on creating a new article? It should, it was possible in the past, why not now?

 

The Second problem is regarding a workaround for the first problem.

After creating a new product i can see in the associations->stock_availables->stock_available a new field with quantity = 0 ( visible and checked via database or via webservice).

So it's troublesome, but if i manage to get the id of my recently created product, i can request via webservice the full data of this product, navigate to associations->stock_availables->stock_available, get the stock_Id, and change the stock!

What a crazy ride just to add stock no?

 

Another workaround would be to enable out of stock orders, since my stock is zero.

From what i can tell, it is a field named out_of_stock that is located in........associations->stock_availables->stock_available!

So, same workload to update stock or to enable out of stock orders.

 

Is there any easier way to add stock upon creating a product via webservice in a single step?

How can i get the id of the product i just created? Shouldn't it be returned in the xml response to the add command?

 

Please help me, i have lot tons of hours trying to get this working with no luck!

Link to comment
Share on other sites

  • 2 months later...

I have founded the way to do it.

 

When you create one product or product attribute combination, one record is inserted on the table stock_available. You can edit this row via webservice.

 Hi! Thanks for stating your solution. Could you give us a summary of the problem you were having. Also, when you edit the row via webservice, what are the changes you are making? When you create a product combination, you edit the stock_available table to what the stock quantity is? 

Link to comment
Share on other sites

  • 1 year later...
  • 1 year later...

Hi ElPepito;

 

the error message is too general, I can't help you with so little information, but i think is obvious there are a problem with the syntax of some xml used.

 

I didn't use this code, but I advise you to check the xml at any point, to find out where the error occurs.

 

One question that can guide. Is the product created despite the error?

 

- If the answer is yes, it confirms your suspect about the line 152, check the xml in $xml_response.

- If the answer is no, check the version of Prestashop and WebService is according to the code

Link to comment
Share on other sites

Hi ElPepito;

 

the error message is too general, I can't help you with so little information, but i think is obvious there are a problem with the syntax of some xml used.

 

I didn't use this code, but I advise you to check the xml at any point, to find out where the error occurs.

 

One question that can guide. Is the product created despite the error?

 

- If the answer is yes, it confirms your suspect about the line 152, check the xml in $xml_response.

- If the answer is no, check the version of Prestashop and WebService is according to the code

 

Thanks for answering edgarrodsil.

The product is created just fine. I did a var_dump($xml_response) and what I get is NULL, so the error is there. But I dont understand what this line is supposed to mean ($xml_response = $xml_request['response']). 

Any help would be appreciated.

Edited by ElPepito (see edit history)
Link to comment
Share on other sites

×
×
  • Create New...