Jump to content

Force_id not working with lang table


Cawet

Recommended Posts

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 :P ?

 

Link to comment
Share on other sites

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 by Cawet (see edit history)
Link to comment
Share on other sites

  • 4 years later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...