Jump to content
Daaaaad

Update product stock

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)

Share this post


Link to post
Share on other sites

Hello neighbor!

What ERP do you use?   With Dolibarr, this function is achievable .... I think.

Share this post


Link to post
Share on other sites

Hi @rhume 😀

That's a custom ERP, designed by another company in windev 🤔

I'm searching how to achieve that using the webservice...

Share this post


Link to post
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...

 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
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...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More