Jump to content

Programmatically adding product but quantity always 0


Crazy-P

Recommended Posts

Hei all on here

 

I have used this thread: https://www.prestashop.com/forums/topic/262781-programmatically-adding-product/ with great success. However, the added products' quantity always remain 0? Everything works out perfectly: title, link_rewrite, price, image etc., just not the quantity.

 

I use: $product->quantity = 1;

 

In the database it remains 0 in psug_stock_available and psug_product.

 

I know I can quickly update the quantity with sql, but I do prefer to use the standard methods via Prestashop.

 

Thank you for your time.

 

Sincerely, Patrick

Link to comment
Share on other sites

Okay. I figured out a way though I don't know if this is the proper way.

For everyone else who encounter this problem then do as following:
 

StockAvailable::setQuantity($id_product, $id_product_attribute, $quantity); //If you don't have a id_product_attribute, then just leave it as "null".
Edited by Crazy-P (see edit history)
  • Like 1
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...