Jump to content

[SOLVED] Product quantity vs Stock_available


Recommended Posts

When creating or updating a product, the amount entered in Quantity is not stored in ps_product.quantity in the database but instead in the stock_available.quantity table linked to the id_product

However, when Product::getProducts() is called, it returns products with the prpduct.quantity value rather than the stock_available.quantity value.

This seems kind of useless. Is there an accepted way of either

a) getting the quantity of stock_available with getProducts()

b) using another existing method to return the actual stock

c) enabling something on prestashop so that the ps_product table is automatically synchronised with the stock_available table?

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

I found an answer for b)

 

$all_products=Product::getProducts($this->lang, 0, 0, 'id_product', 'ASC', false,true,null);

foreach ($all_products as $prod)
            {

$prod['quantity']= StockAvailable::getQuantityAvailableByProduct($prod['id_product'],null,null);

}

and re-add the items to the array

Link to comment
Share on other sites

  • Ikoshop changed the title to [SOLVED] Product quantity vs Stock_available

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