Hi,

I want to maintain source-id in create-stub function also, node_save always return new nid only. How to achieve this?

code i used:
protected function createStub($migration, array $source_id) {
dpm($this->destination, 'this');
dpm($source_id[0], 'source');
migrate_instrument_start('DrupalNodeMigration::createStub');
$node = new stdClass;
$node->title = t('Stub');
$node->body = array(LANGUAGE_NONE => array(array("value" => t('Stub body'))));
$node->type = $this->destination->getBundle();
$node->uid = 1;
// $node->nid = $source_id[0];
//$node->vid = $migration->vid;
dpm($node, 'Before');
node_save($node);
migrate_instrument_stop('DrupalNodeMigration::createStub');
dpm($node, 'After');
if (isset($node->nid)) {
return array($node->nid);
}
else {
return FALSE;
}
}

Comments

tssarun created an issue. See original summary.

hargobind’s picture

Status: Active » Closed (duplicate)

I think what you want is this issue #2287757: Wizard option to retain node/user IDs which discusses how to do this, including a couple of code examples.

tssarun’s picture

No I want maintain inside createStub, not in mapping field. I solved by adding $node->is_new = TRUE;

Regards,
tssarun.