I'm migrating to drupal 7 from an old content management system. I have broken the node up into 16 different content types that currently have identical fields. This is to allow those different types to diverge later. Currently I have a generic migration class that is then inherited by 16 different migration classes, that modify the query to limit it to just nodes of the right type. I then run the group that contains all 16 of those migrations, followed by two field collection migrations that populate nodes from all 16 of those migrations. The issue with this approach, aside from the increased database activity and a likely slowdown, is that when I view the recently entered content it all ends up being from the last content type that was imported. It would be much nicer to be able to determine the content type on the fly.

It there any way to override the bundle defined in this line:

$this->destination = new MigrateDestinationNode('document');

Comments

ultrabob created an issue. See original summary.

manojbisht_drupal’s picture

HI,

There is no such method through which u can dynamically change content type of MigrateDestinationNode.

However what u can do is, assign ur entity property (node_type and bundle) in prepare function by meeting certain criteria.

like

if( condition 1 ) :
then
$entity->type = 'product_1';
$entity->bundle = 'product_1';
else
$entity->type = 'product_2';
$entity->bundle = 'product_2';

manojbisht_drupal’s picture

Status: Active » Fixed
ultrabob’s picture

That worked great. Thank you!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.