Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have the following migration to import blog posts with multiple tags:
$this->destination = new MigrateDestinationNode('blog_post');
$this->addFieldMapping('field_tags', 'tags')
->sourceMigration('BlogTags');
$this->addFieldMapping('field_tags:source_type')
->defaultValue('tid');
This code gets the terms for the blog post:
public function prepareRow($row) {
db_set_active('wp');
$results = db_query("SELECT c.term_id, c.name FROM {wp_term_relationships} a INNER JOIN {wp_term_taxonomy} b ON a.term_taxonomy_id = b.term_taxonomy_id INNER JOIN {wp_terms} c ON c.term_id = b.term_id WHERE b.taxonomy = 'post_tag' AND a.object_id = :id", array(':id' => $row->ID));
foreach ($results as $r) {
$row->tags[] = $r->term_id;
}
db_set_active('default');
}
This works fine and the new posts have associated tags. However, the migration messages shows hundreds of Field validation error for field_tags: Tags: illegal value. errors.
Is there something I can do to prevent these?
Comments
Comment #2
cameron prince CreditAttribution: cameron prince at Mediacurrent commented