How do I manually set tnid when migrating nodes? I need to manually set tnid during migration.

My code:

  public function complete($entity, $row) {

    // load the newly created node (just in case entity isn't fully populated).
    $node = node_load($entity-&gt;nid);
    $node-&gt;tnid = '66';
    $node-&gt;title = 'CHANGE THIS !';

    // create the field collection item entity
    $item = entity_create('field_collection_item', $values);

    // attach it to the node loaded above
    $item-&gt;setHostEntity('node', $node);

    // save the entity
    $item-&gt;save();
  }


The node 66 exists and is active, but when I check on translations, the new node isn't associated. Instead the  title is changed with "changed this", then the new node is updated.

With Devel I see that the node has tnid 66.
You want to give the node a language, and set the source node in the translation_source key:

$node-&gt;language = 'es';
$node-&gt;translation_source = node_load(66);


Reference: https://api.drupal.org/api/drupal/modules!translation!translation.module/function/translation_node_prepare/7