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->nid);
    $node->tnid = '66';
    $node->title = 'CHANGE THIS !';

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

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

    // save the entity

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.

  • Hi, monkeyUser. What do you mean "check on translations"? Sep 6, 2015 at 6:11

1 Answer 1


You want to give the node a language, and set the source node in the translation_source key:

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.