Prestashop 使用模块添加产品,不能强制 product_id [英] Prestashop adding product using module, cant force product_id
问题描述
正如主题所说,我在添加产品时遇到问题(通过使用产品类).一切正常,但即使我指定 $product->id = 1234;它不会用这个 id 保存它,它只是自动增加数据库中的产品.但我真的需要将我自己的 product_id 插入到数据库中(因为我从地面 strone 数据库中导入产品并且它们需要经常更新)
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)
这是我的代码:
$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();
那么有没有办法插入我自己的产品ID?
So is there any way to insert my own product id ?
推荐答案
我设法通过添加 $_GET['forceIDs'] = 1 来修复它或者干脆在 url 末尾设置 ?forceIDs=1.
I managed to fix it by adding $_GET['forceIDs'] = 1 or simply do ?forceIDs=1 at the end of url.
这篇关于Prestashop 使用模块添加产品,不能强制 product_id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!