First of all. I know Migrate support for Address Field was available in Migrate Extras and I know that since Migrate 2.6 we fall back on a default field handler in Migrate. However, this field handler does not support multiple values for fields other that the main value. meaning that we cannot migrate data into a multivalued address field.
I think we should therefore add a Migrate handler for the Address Field and since Migrate Extras is obsolete and the correct place for adding Migrate support is in the module itself, I opened the issue here and not in the Migrate Extras issue queue.
Patch will soon follow.
Comment | File | Size | Author |
---|---|---|---|
#2 | addressfield-better_migrate_support-2013543-2.patch | 9.03 KB | xatoo |
#1 | addressfield-better_migrate_support-2013543-1.patch | 7.13 KB | xatoo |
Comments
Comment #1
xatoo CreditAttribution: xatoo commentedComment #2
xatoo CreditAttribution: xatoo commentedI've changed the patch to store additional data as a serialized array in the 'data' column so that it can now be used with extensions to address field, (like Address Field Phone.)
Example:
Comment #3
kostajh CreditAttribution: kostajh commentedThis patch worked great for me. Thanks for contributing it!
Even though you've documented this in the code, it might be worth throwing an exception if someone tries to migrate country names that are longer than two characters (or perhaps better, are not valid ISO country codes). As it stands, you'll get SQL errors when trying to migrate "United States" in place of "US".
Comment #4
bc CreditAttribution: bc commentedTested and works for me, as well. Thanks for the patch :)
Comment #5
dwkitchen CreditAttribution: dwkitchen commentedAlso worked for me
Comment #6
rszrama CreditAttribution: rszrama commentedCommitting as is. I'm not sure where such an exception for invalid country codes would go in the Migrate class, but I'd be happy to patch that in if it's an accepted pattern for Migrate classes.
Comment #8
ShaunDychko CreditAttribution: ShaunDychko for Bellin commentedNot sure if this belongs in docs somewhere, but here's a suggested starting point for someone migrating into Address Field with country names in the source. This does Google geocoding since Google can understand typos in the country name, returning DE for "ermany", "Gerany", and other typos. In the migrate constructor use
$this->addFieldMapping('my_destination_address_field', 'country_code');
The following takes inspiration from the Geocoder module, and requires it to be enabled with a Google API key entered.