a1000car Posted June 13, 2013 Share Posted June 13, 2013 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 More sharing options...
a1000car Posted June 14, 2013 Author Share Posted June 14, 2013 Can someone help out please? Link to comment Share on other sites More sharing options...
edgarrodsil Posted September 3, 2013 Share Posted September 3, 2013 Hi a1000car I have the same problem, have you solved it? Link to comment Share on other sites More sharing options...
edgarrodsil Posted September 3, 2013 Share Posted September 3, 2013 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. Link to comment Share on other sites More sharing options...
benjamin utterback Posted September 3, 2013 Share Posted September 3, 2013 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 More sharing options...
xabikip Posted February 7, 2015 Share Posted February 7, 2015 It could be done by taking the id of stock_available response when a product is created. But how pick the data returned? exactly the id of stock_available Link to comment Share on other sites More sharing options...
xabikip Posted February 10, 2015 Share Posted February 10, 2015 I can solve this. Anyone want the result? Link to comment Share on other sites More sharing options...
popking Posted February 17, 2015 Share Posted February 17, 2015 i want the result please Link to comment Share on other sites More sharing options...
xabikip Posted February 18, 2015 Share Posted February 18, 2015 You can see an example there: https://github.com/xabikip/PrestaShopWebService/blob/master/examples/createProduct.php If you have any question ask. Link to comment Share on other sites More sharing options...
popking Posted February 19, 2015 Share Posted February 19, 2015 You can see an example there: https://github.com/xabikip/PrestaShopWebService/blob/master/examples/createProduct.php If you have any question ask. Awesome, thanks! Link to comment Share on other sites More sharing options...
ElPepito Posted March 31, 2016 Share Posted March 31, 2016 You can see an example there: https://github.com/xabikip/PrestaShopWebService/blob/master/examples/createProduct.php If you have any question ask. Hi, when I use this code it gives me the following error: String could not be parsed as XML any ideas? Link to comment Share on other sites More sharing options...
xabikip Posted March 31, 2016 Share Posted March 31, 2016 In what line you have the error? Link to comment Share on other sites More sharing options...
ElPepito Posted March 31, 2016 Share Posted March 31, 2016 (edited) it doesnt tell me in which line I have the error, but I think that it is on lines 151,152 or 153. Thanks for answering. Edited March 31, 2016 by ElPepito (see edit history) Link to comment Share on other sites More sharing options...
edgarrodsil Posted April 1, 2016 Share Posted April 1, 2016 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 More sharing options...
ElPepito Posted April 1, 2016 Share Posted April 1, 2016 (edited) 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 April 1, 2016 by ElPepito (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts