Jump to content

Update product stock


Daaaaad

Recommended Posts

Hello everyone !

We are synchronizing our shop with an ERP using the PrestaShop's webservice.

We would like the ERP to set the product quantities (via the API) frequently but take the "reserved quantities" (already ordered products) into account.

Example :

Physical stock = 100
Reserved quantities = 2
Available quantities = 98

We receive 50 new products :

Physical stock = 150
Reserved quantities = 2
Available quantities = 148

The ERP do not know how much products have been sold.

How to achieve that? Use stock movements?

We are using PrestaShop 1.7.5.

Thank you 😀

 

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

Hi,

Can you create a PHP on the prestashop's server ?

If yes you can use object 

StockAvailable::getQuantityAvailableByProduct

and StockAvailable::setQuantity

Beware to stock movement ...

Else you can use Webservice, look :

$xml = $webService->get(array('url' => PS_SHOP_PATH . '/api/products')); 
$opt['resource'] = 'products';
$opt['id'] = $id_ps_produit;
$xml = $webService->get($opt);
foreach ($xml->product->associations->stock_availables->stock_available as $stock) {
   $xml2 = $webService->get(array('url' => PS_SHOP_PATH . '/api/stock_availables?schema=synopsis'));
etc...

 

Link to comment
Share on other sites

  • 2 weeks later...

Hello @a17000,

Thank you but neither StockAvailable::getQuantityAvailableByProduct nor StockAvailable::setQuantity are taking "reserved_quantity" into account 😔

As I said above, I would like to update the physical stock quantities but keep "reserved_quantity" reserved and recalculate the available quantities...

David.

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...