Jump to content

Prestashop 1.7 Product quantity doesn't update when creating programatically


Recommended Posts


I'm trying to create a product programatically using ProductCore class. Product is being created but quantity always stays at 0 while in my code I set it to 5. Any suggestions?

Code that I'm using and working perfectly apart quantity:

$product = new ProductCore();
$product->reference = '123456';
$product->quantity = 5;
$product->name = "Sample product";
$product->link_rewrite = array((int)Configuration::get('PS_LANG_DEFAULT') =>  Tools::str2url("Sample product"));
$product->id_category_default = 2;
$product->category = 2;
$product->price = 50;

Using Prestashop

Edited by TomBar (see edit history)

Share this post

Link to post
Share on other sites

1 hour ago, gusman126 said:

try use 


StockAvailable::setQuantity($id_product, $id_attribute, $quantity, $id_shop = null);

This is the solution. Thank you.

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