Jump to content

Edit History

Vortek

Vortek


prestashop version

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.

Vortek

Vortek

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.

Thanks for the help.

×
×
  • Create New...