drupal - Yaml, mapping multiple values -


i trying improve upon wordpress drupal 8 migration module (https://github.com/amitgoyal/d8_migrate_wordpress) , add functionality import taxonomy terms. have written queries join taxonomy terms posts, having trouble assigning multiple terms field (called tags, entity reference taxonomy terms) of drupal content type article. have created manifest file mapping article content type:

id: posts label: wordpress posts migration_groups:   - wordpress source:   plugin: posts destination:   plugin: entity:node process:   nid: id   vid: id   type: type   langcode:     plugin: default_value     default_value: "und"   title: post_title   uid: post_author   status:     plugin: default_value     default_value: 1   body/value: post_content   body/format: normal   field_image/target_id: post_image   field_tags/target_id: terms 

in posts.php file, handles fetching , processing of wordpress data, have function (prepareterms), sets property 'terms', used yaml file above. if set single value works expected:

$terms = '4'; $row->setsourceproperty('terms', $terms); 

however, want set property array (for multiple taxonomy terms), below:

$results = $query->execute()->fetchall();  $terms = array(); foreach($results $term) {   $terms[] = $term['term_id']; } //$terms = yaml::dump($terms); $row->setsourceproperty('terms', $terms); 

as each taxonomy term should number (term id), should passing array of integers, cannot seem map 'field_tags'. have tried using yaml::dump before setting 'terms' property in posts.php. have tried changing yaml template hardcode these, below:

field_tags/target_id: [1, 2]  field_tags/target_id: {0:1, 1:2}  field_tags: {target_id: 1, target_id:2} 

linked screenshot of dummy node created have assigned 2 taxonomy terms (loaded through devel) - http://imgur.com/nkqqong

any stronger appreciated!

fixed, combination of incorrect array formatting, , setting wrong target in yaml. code looks like:

posts.php

#hardcoded $terms = array(array('target_id'=>'1'), array('target_id'=>'2')); 

posts.yml

field_tags: terms 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -