Jump to content

Webservice - Get Product Quantity in the product itselt


Recommended Posts



I am  new to Prestashop. Currently i am able to access my store through webservice and do all the CRUD operations successfully with the help of this official tutorial.



I need a custom option of receiving the product (or) product list with the quantity of stock_availables in the product itself, without the need to query again with the stock_available id of the product. 


Thanks in Advance.

Link to comment
Share on other sites

After some trial and error, i found the below way to get the product quantity in the product itself on webservice if you don't have combinations. 


Go to file /classes/Product.php


Search around line 387 for 


           'quantity' => array(

                'getter' => 'false',
                'setter' => false


and change it to 


           'quantity' => array(

                'getter' => 'getMyStockforWebService',
                'setter' => false
Then add the following method.
 public function getMyStockforWebService(){
    return StockAvailable::getQuantityAvailableByProduct($this->id, 0);
This might help someone
Link to comment
Share on other sites

  • 2 years later...
  • 9 months later...

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