Jump to content

Multiple Stock quantity update on one API call


Vortek

Recommended Posts

Hi there,

I am able to update the stock for a product but I need to update more than one using one request. I have a query that gets IDs and Quantities, and then if I iterate I am able to update the stock, one by one. As there are about 3000 products, I need to send them in bulk.

Current working code:

while($row = $results->fetch_row()) {
           
           // get stock
           $xml_single_call = $webService->get(array("resource" => "stock_availables", "id" => $row["id"]));
           
           // update quantity
           $xml_single_call->children()->children()->quantity = $row["quantity"];
           
           // send to API
           $xml_after_put = $webService->edit(array("resource" => "stock_availables", "id" => $row["id"], "putXml" => $xml_single_call->asXML()));
      }

I have tried iterating on the "Stocks_available" full XML, but I always get an error when submitting.

Using prestashop 1.7.6.7.

Thanks for the help.

Edited by Vortek
prestashop version (see edit history)
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...