问题
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