Cawet Posted June 13, 2017 Share Posted June 13, 2017 hi, If a objectModel has the multilang options set to true in his definition, this code: $obj = new myObject($myId, $mylang); $obj->force_id = true; $obj->add(); while use 0 has id for the language table. i think is because of this line in the add method of the ObjectModelCore class: (491) // Get object id in database $this->id = Db::getInstance()->Insert_ID(); juste before the insertion in the lang table. change it to // Get object id in database if (isset($this->id) && !$this->force_id) { $this->id = Db::getInstance()->Insert_ID(); } make it work for me. Am I doing wrong, have got a miss configuration, or could we say that this is a core bug and i found a improvement ? Link to comment Share on other sites More sharing options...
Nishith Nesdiya Posted June 15, 2017 Share Posted June 15, 2017 Hi...you need use Context Object for language idhttp://doc.prestashop.com/display/PS16/Using+the+Context+ObjectThanks Link to comment Share on other sites More sharing options...
Cawet Posted June 15, 2017 Author Share Posted June 15, 2017 (edited) Hi, what do you mean? The problem isn't that i don't know how to set the language id, i've got the same problem with this: $context = Context::getContext(); myId = 45654 ; $obj = new myObject($myId, $context->language->id); $obj->force_id = true; $obj->add(); [....] while use 0 has id for the language table. I don't mean about the language id, i mean for the table id, for the language table =) Edited June 15, 2017 by Cawet (see edit history) Link to comment Share on other sites More sharing options...
jf Viguier Posted July 27, 2021 Share Posted July 27, 2021 Thanks @Cawet i've made a pr inspired by your code https://github.com/PrestaShop/PrestaShop/pull/25433 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now