rickczsu Posted May 30, 2015 Share Posted May 30, 2015 (edited) 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 August 9, 2015 by rickczsu (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted May 30, 2015 Share Posted May 30, 2015 in prestashop it's almost impossibledatabase of prestashop ps_products table is based on unique field, it's INT with AUTO_INCREMENT paramthis means that id can't be duplicated, and changed without destroying database consistency Link to comment Share on other sites More sharing options...
rickczsu Posted May 30, 2015 Author Share Posted May 30, 2015 (edited) 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 Edited May 30, 2015 by rickczsu (see edit history) Link to comment Share on other sites More sharing options...
rickczsu Posted May 30, 2015 Author Share Posted May 30, 2015 So only way I can do that is create my own table where original id and prestashop id will be stored? Link to comment Share on other sites More sharing options...
vekia Posted May 30, 2015 Share Posted May 30, 2015 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 More sharing options...
rickczsu Posted May 30, 2015 Author Share Posted May 30, 2015 You are right. I will create my own two tables which will compare all imported data ids. It´s only safe solution. Thank you for your response Link to comment Share on other sites More sharing options...
Recommended Posts