5

Is it possible to include extra arguments when migrating via command line?

I have a custom migration which migrates XML content into Drupal as entities. However, each XML document of migrated entities need to be associated with a different node.

I'm successfully doing this entities to node association via the following code:

function complete($entity, stdClass $row) {
    $node = node_load(1);
    $node->field_questions[$node->language][ sizeof($node->field_questions[$node->language]) ]['target_id'] = $entity->id;
    node_save($node);
}

As you can see from the code, the NID is hardcoded. Of course, the NID could be extracted from the XML input but it is unknown in advance of the migration.

So, I just wonder if running drush migrate Questions could be run with custom arguments where I could specify the target NID to associate my migrations with? Something like, drush migrate Questions --nid=10

1

In the URL below you can find Dush arguments for migrations. Following the documentation you need --idlist argument.

enter image description here

See here https://www.drupal.org/node/1561820

Hope that helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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