Jump to content

[SOLVED] Product - own ids - update function


Recommended Posts

Hi,
can you help me pls? When I try to update product programmatically, I can´t set my own ids. When I did the same in category I just manually inserted my own category id to database and then just putted data and everything was ok.
When I try to do the same with products, it don´t works. When I use save function it add new product with new id. When I use update, it don´t change anything without any warning.

For example
$p = new Product();
$p->id_product = (int) $id;
$p->.....
$p->update();

As I said. $p->save() works so it´s not source code fault. I know I missed something, but what it is? Thanks

Edited by rickczsu (see edit history)
Link to comment
Share on other sites

in prestashop it's almost impossible
database of prestashop ps_products table is based on unique field, it's INT with AUTO_INCREMENT param
this means that id can't be duplicated, and changed without destroying database consistency :(

Link to comment
Share on other sites

But category is same as product with autoincrement ids and there it´s possible...

I just insert my own ID to database and then run update with all values

 

it works now, but in the future... who knows

database consistency is most important thing, if you will add some contents in the future via shop back office - this can screw up db

Link to comment
Share on other sites

×
×
  • Create New...