Jump to content

Edit History

TomBar

TomBar

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

TomBar

TomBar

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();

 

×
×
  • Create New...