Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Currently if the source data lists the country with its full name, import will fail as addressfield's importer requires ISO two-letter country code.
It would be very nice if it automatically checked if the data is greater than 2 letters, and then translated country->code using country_get_list.
Comments
Comment #1
rerooting CreditAttribution: rerooting commentedI have a way to do this that I'm unsure of how to add to the (legacy) destination handler, however I have done something similar with my Migration class:
this is in my Migration class:
then, in my .module file I added this:
This converts, for example, a source value of "United States" to 'US' using the same approach that addressfield itself currently uses to expose the full country label in it's field handler. The field destination handler will change with addressfield 2.x's new approach to storing all of this address information, but will continue to work regardless.
I should mention that I did this with migrate 2.6's default field handler and the latest dev of migrate_extras, which doesn't include the addressfield handler at all. This same approach will work with the legacy addressfield handler and 2.5 just fine as well.