2

I migrate Drupal 6 to Drupal 8. In Drupal 8 I have content type that has field with type Entity reference that reference specific taxonomy dictionary. I can't find out how to set Entity reference field target_id in yml migration file. I have tried:

field_my_field:
  plugin: iterator
  source: field_my_field
  process:
    target_id:
      plugin: default_value
      default_value: 19

I would expect that code above set Entity reference (field_my_field) to reference term with id 19 (that already exists). There is no error (or message) and default_value plugin is called correctly a returns 19. But in migrated content is not reference set.

I tried to set reference manually and then dump it and result was:

[field_my_field] => Array
  (
    [x-default] => Array
      (
        [0] => Array
          (
            [target_id] => 19
          )
      )
  )

I have tried lot of other ways how to set entity reference target_id but nothing actually work. Do anybody know how to set entity reference target_id in migration yml file?

  • 1
    Hi do you any update on this? I'm facing the same situation, my code is very similar, everything seems to run well, but the association is not saved. – jchatard Sep 21 '17 at 15:43
0

Is 19 the tid of an already-existing Drupal 8 term in the vocabulary that field_my_field is configured to reference? If so, I don't really see where the example using default_value would be going wrong...

0

Old question, but I'm guessing you need to add the array for the item list. I was successful with: field_something/0/target_id: YOUR_VALUE_HERE

I haven't found documentation on the slash in the field id, but it is an array notation. The above is equivalent to something like: $destination_values['field_something'][0]['target_id'] = YOUR_VALUE_HERE

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.