Migrating a Drupal 7 AddressField To a Drupal 8 Address
Why I Am Writing This
There seems to be a lot of confusion in the forums when you Google "How to migrate an address field". Some of the posts are much older, so that is acceptable. However, for well over a year now the Drupal 8 Address module has their migration process built into the module. If you are looking for the right and easy way to migrate a Drupal 7 Addressfield to a Drupal 8 Address, keep on reading.
Quick and Easy
When performing migrations for any contrib or core module, always check its src/Plugin directory for a migrate folder. A lot of time, the solution you are searching for is right there. In the case of the Drupal 8 Address module, the answer to our problem is in that directory.
The Drupal 8 Address module has a MigrateField plugin in the migrate/source folder named addressfield. This plugin gets the Drupal 7 addressfield for us to use in our migration. Then, if you look in the migrate/process folder, you will see the MigrateProcessPlugin also named addressfield. We will utilize that plugin to handle our task at hand.
The solution is pretty simple now that we have discovered these plugins. In your migration YAML, all you need to do is this:
process: field_address: - plugin: addressfield source: field_address
Pretty straight forward and easy. Just like any other process plugin used in a Drupal 8 migration, this one gets the job done for us.
When doing a migration, always check first in the src/Plugin/migrate folder of the modules / entity you are trying to migrate. The Drupal 8 migration system has matured a lot over the past 3 years. More often than not, your solution is already baked in. If your organization needs help with a Drupal 8 Migration, Contact Us to chat more about it!