Prestashop adding product using module, cant force product_id

人盡茶涼 提交于 2019-12-13 15:07:47

问题


As topic says i have problem with adding product (by using product class). Everything works fine but even if i specify $product->id = 1234; it doest save it with this id, it just autoincrements products in database. But i really need to insert my own product_id into database (since i import products from ground strone database and they'll need to be updated often)

Here is my code:

$langId = (int) (Configuration::get('PS_LANG_DEFAULT'));
$p = new Product($prod['towar_id']);
$p->id = $prod['towar_id'];
$p->name = array($langId => $prod['nazwa']);
$p->ean13 = $prod['kod'];
$p->id_category_default = 6;
$p->category = array(6);
$p->link_rewrite = array($langId => Tools::link_rewrite($prod['nazwa']));
$p->weight = $prod['ile_kg_litrow'];
$p->quantity = $prod['magazyny']['magazyn']['stan_magazynu'];
$p->price = $prod['cena_detal'];
$p->add();

So is there any way to insert my own product id ?


回答1:


I managed to fix it by adding $_GET['forceIDs'] = 1 or simply do ?forceIDs=1 at the end of url.



来源:https://stackoverflow.com/questions/13528720/prestashop-adding-product-using-module-cant-force-product-id

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!