Jump to content

Prestashop 1.7 Product quantity doesn't update when creating programatically


TomBar

Recommended Posts

Hello,

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;
$product->add();

Using Prestashop 1.7.6.5

Edited by TomBar (see edit history)
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...