diff --git a/web/modules/custom/agaric_migration/migrations/agaric_blog.yml b/web/modules/custom/agaric_migration/migrations/agaric_blog.yml index 41f5bf4..4014e7e 100644 --- a/web/modules/custom/agaric_migration/migrations/agaric_blog.yml +++ b/web/modules/custom/agaric_migration/migrations/agaric_blog.yml @@ -2,7 +2,7 @@ id: agaric_blog migration_group: agaric label: Agaric Blog source: - plugin: d7_node + plugin: agaric_node node_type: blog destination: plugin: entity:node @@ -61,6 +61,18 @@ process: plugin: migration_lookup source: node_uid migration: agaric_people + field_tags: + plugin: sub_process + source: field_tags_names + process: + target_id: + - plugin: entity_generate + source: name + value_key: name + bundle_key: vid + bundle: tags + entity_type: taxonomy_term + ignore_case: true migration_dependencies: required: - agaric_people diff --git a/web/modules/custom/agaric_migration/src/Plugin/migrate/source/AgaricNode.php b/web/modules/custom/agaric_migration/src/Plugin/migrate/source/AgaricNode.php new file mode 100644 index 0000000..5c285ae --- /dev/null +++ b/web/modules/custom/agaric_migration/src/Plugin/migrate/source/AgaricNode.php @@ -0,0 +1,40 @@ +getSourceProperty('nid'); + // Get the taxonomy tags names. + $tags = $this->getFieldValues('node', 'field_tags', $nid); + $names = []; + foreach ($tags as $tag) { + $tid = $tag['tid']; + + $query = $this->select('taxonomy_term_data', 't'); + $query->condition('tid', $tid); + $query->addField('t', 'name'); + $result = $query->execute()->fetchAssoc(); + $names[] = ['name' => $result['name']]; + } + $row->setSourceProperty('field_tags_names', $names); + + return parent::prepareRow($row); + } + +}