伙计们,我尝试使用以下代码从模块创建自定义产品:
$defaultLanguage = new Language((int)(Configuration::get('PS_LANG_DEFAULT')));
/* Add a new product */
$object = new Product();
$object->price = 22;
$object->id_tax_rules_group = 0;
$object->name = 'test';
$object->id_manufacturer = 0;
$object->id_supplier = 0;
$object->quantity = 1;
$object->minimal_quantity = 1;
$object->additional_shipping_cost = 0;
$object->wholesale_price = 0;
$object->ecotax = 0;
$object->width = 0;
$object->height = 0;
$object->depth = 0;
$object->weight = 0;
$object->out_of_stock = 0;
$object->active = 0;
$object->id_category_default = 18;
$object->category = 18;
$object->available_for_order = 0;
$object->show_price = 1;
$object->on_sale = 0;
$object->online_only = 1;
$object->meta_keywords = 'test';
if($object->save())
$object->add();
echo "produit ajouté";
代码工作正常,产品已添加到数据库中但没有显示在后台,有人有解决这个问题的想法吗?