0

I am attempting to do a simple migration of an image from a D6 CCK file field to a D8 file field, and for some reason it's not working. Following best practices, I've run a separate file migration - named 'file' - and so now I want to just migrate the fid reference during the node migration. In my blog node migration, I have this in the process section:

field_image:
  plugin: d6_cck_file
  source: field_thumbnail
  migration: file

where field_image is the name of the D8 file field, and field_thumbnail is the source D6 field.

The problem is that the image reference is not being migrated to the D8 field (field_image). In going through the code with my debugger, I'm noticing that the CckFile::transform() method is not being called at all (although __construct() and create() methods are being called), and that's where the finding of the fid in the file migration happens.

Is there something I'm missing in my config? It seems pretty straightforward, so I'm not sure what I'm missing.

Thanks.

UPDATE: After doing some debugging, I found that when the process gets to this line in MigratExecutable:processRow() where the $destination is field_image:

$value = $plugin->transform($value, $this, $row, $destination);

the value of $plugin->id is get, not d6_cck_file. I can't understand why, since the plugin name is clearly defined as d6_cck_file in the migration config.

UPDATE 2: After doing some reading, I'm thinking I might need to use the iterator plugin, since both my source and destination fields are multi-value fields (i.e. they are allowed to have multiple values, even if they actually don't). So I'm trying this:

  field_image:
    plugin: iterator
    source: field_thumbnail
    process:
      field_image_target_id:
        plugin: migration
        migration: file
        source: fid

but that's not getting it either. Still debugging...

UPDATE 3: So with this most recent setup, my destination id is being found correctly, but the issue seems to be the destination. field_image_target_id is the name of the db field where the value is stored, but apparently not the destination value to use. I also tried 'field_image/target_id, but that didn't work, either. What would be the correct destination?

0

So the final solution that worked for this is as follows:

field_image:
  plugin: iterator
  source: field_thumbnail
  process:
    target_id:
      plugin: migration
      migration: file
      source: fid
    alt: alt
    title: title
    height: height
    width: width

As explained to me by @mikeryan, the iterator plugin allows you to iterate over multiple values which have subfields, and map the subfields in the internal process pipeline the way fields are at the top level. In this case, I just used the migration plugin to get the target fid from the file migration, and this puts it in the field_image_target_id column in node__field_image table.

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.