Convert address to multi value during migration I have a migration that imports data into my address field and it works perfect.

  field_address/locality:
    -
      plugin: get
      source: city
  field_address/postal_code:
    -
      plugin: get
      source: postalcode



The problem I am running into is that some data from my source has multiple values in the city so I need to add some logic that if it has multiple cities, create 2 address field values (multi-value).

I was thinking to make a destination plugin. As a proof of concept I tried to edit Drupal\migrate\Plugin\migrate\destination\Entity::getEntity() with the below options but none of them worked:

$row-&gt;setDestinationProperty("field_address/locality", ['Chicago', 'Oakbrook']);


$row-&gt;setSourceProperty("field_address/locality", [0 =&gt; ['value' =&gt; 'Chicago'], 1 =&gt; ['value' =&gt; 'Oakbrook'], []]);


$row-&gt;setDestinationProperty("field_address/0/locality", 'Chicago');
$row-&gt;setDestinationProperty("field_address/1/locality", 'Oakbrook');
I was able to accomplish this by creating a custom process plugin for the address field.

  field_address:
    -
      plugin: myaddress
      source:
        locality: city
        administrative_area: state
        postal_code: postalcode


&lt;?php

namespace Drupal\my_migration\Plugin\migrate\process;

use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Row;

/**
 * Maps values for address.
 *
 * @MigrateProcessPlugin(
 *   id = "myaddress"
 * )
 */
class MyAddress extends ProcessPluginBase {

  /**
   * {@inheritdoc}
   */
  public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {

    $parsed = [];
    // If city name has `and` or `or` it will create multiple address items.
    $cities = preg_split("/ (or|and) /", $value[0]);
    foreach ($cities as $city) {
      $data['country_code'] = 'US';
      $data['locality'] = $city;
      $data['administrative_area'] = $value[1];
      $data['postal_code'] = $value[2];
      $parsed[] = $data;
    }

    return $parsed;
  }

}


My plugin checks to see if there is a string and or or and if there is it converts it multiple values.  Of course, this works out for me because all are US and the cities are for the same state.