0

OK, for a number of reasons I'm doing a Drupal 8 - Drupal 8 migration using the JSON:API module on the source site. I've run into an issue attaching taxonomy terms to nodes. Here's as far as I've gotten :

1) I created a vocabulary called "Photo Categories"

2) I've created and run import_drupal_taxonomy_photo_categories to import the terms. This works perfectly. I have manually checked to ensure they all get in. I use the UUID as the migration's unique identifier.

3) I have a content type called Photos, it has a field called Photo Category which references the Photo Categories vocabulary.

4) From the source JSON in the relationships section I see this:

"field_photo_category": {
   "data": [
     {
       "type": "taxonomy_term--photo_categories",
       "id": "84c1e8bd-16f7-429f-b299-50fe43297d47"
     },
     {
       "type": "taxonomy_term--photo_categories",
       "id": "00931a31-d129-4c55-a962-f7ba11fed5a4"
     }
  ],
  "links": {
    "self": "https:\/\/seanreiser.com\/jsonapi\/node\/photo\/1396b571-0ece-4a07-ab17-7327e030dfb5\/relationships\/field_photo_category",
    "related": "https:\/\/seanreiser.com\/jsonapi\/node\/photo\/1396b571-0ece-4a07-ab17-7327e030dfb5\/field_photo_category"
  }
}

5) In the source > Fields section of import_drupal_type_photo I have:

- 
  name: field_photo_category
  label: 'Field Photo Category'
  selector: /relationships/field_photo_category/data

6) In the process section I have:

  field_photo_category:
    plugin: iterator
    source: field_photo_category
    process:
       plugin: migration_lookup
       migration: import_drupal_taxonomy_photo_categories
       source: id

As I understand it this should loop through the field_photo_category.data and do a migration lookup on each id. But nothing is getting mapped.

I have verified that the ids match the ids in the data section match the UUID from the taxonomy term JSON. I have checked the database and verfied that ids appear in migrate_map_import_drupal_taxonomy_photo_categories.soure1 and they map to the appropriate tids.

I have installed the migrate devel module and when I run the migration with --migrate-debug this is what the destination section look like:

  'field_photo_category' => array (2) [
        array (1) [
            'source' => string (36) "84c1e8bd-16f7-429f-b299-50fe43297d47"
        ]
        array (1) [
            'source' => string (36) "00931a31-d129-4c55-a962-f7ba11fed5a4"
        ]
    ]

So, my question, what am I doing wrong? I have the rest of this part of my migration laid out and this seems to be the final obstacle.

Thanks in Advance

  • The plugin should be sub_process. – Kevin May 10 at 23:01
  • I tried it with a sub_process with the same result, so that's not it, but thanks. – Sean Reiser May 11 at 3:56
2

Entity reference fields need to fill their target_id column

field_photo_category:
  plugin: sub_process
  source: field_photo_category
  process:
    target_id:
       plugin: migration_lookup
       migration: import_drupal_taxonomy_photo_categories
       source: id

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.