I've discovered that the fields available to Migrate via the location.migrate.inc file are hard-coded and are not compatible with add-in modules that use the Location API to add fields, like Location Phone.
The problem lies here; this array needs to be dynamically generated based on enabled modules that implement hook_locationapi().
/**
* Implementation of hook_migrate_fields().
*/
function location_migrate_fields_location($type) {
$fields = array(
'[lid]' => t('Location ID'), // Primary Key: Unique location ID.
//'locpick' => t('Location Chosen By User?'),
'nid' => t('NID'), // nid
'vid' => t('VID'), // vid
//'uid' => t('User ID'), only used for location_user? (manual ones have uid of 0)
'genid' => t('Generic reference key'), // Generic reference key.
'name' => t('Location Name'), // Place Name.
'street' => t('Street Address'), // Street address, line 1.
'additional' => t('Additonal info'), // Street address, line 2.
'city' => t('City'), // City.
'province' => t('Province/State'), // State / Province code.
'postal_code' => t('Postal Code'), // Postal / ZIP code.
'country' => t('Country (2 letter code)'), // Two letter ISO country code.
'latitude' => t('Latitude'), // Location latitude (decimal degrees).
'longitude' => t('Longitude'), // Location longitude (decimal degrees).
'source' => t('Source'), // Source of the latitude and longitude data (Geocoder, user entered, invalid, etc.)
'is_primary' => t('Primary Location? (deprecated)'), // Is this the primary location of an object? (unused, civicrm legacy field?)
'inhibit_geocode' => t('Inhibit Geocoding?'), //
);
return $fields;
}
Any suggestions as to how to remedy this?
Comments
Comment #1
chiddicks commentedOne possible solutions is to invoke the hook_locationapi hook within this function to determine extra fields, but that seems like poor form.
Comment #2
Anonymous (not verified) commentedHere is a quick hack, for those who need this functionality now for particular extra fields. In my case, I needed
phoneandfax, provided bylocation_phoneandlocation_fax.This is for 6.x-2.0, I don't know if it will work with Migrate v1.
First, enable
location_phoneandlocation_faxmodules.Set them as dependencies in your custom migration module, too. If your module is
mymodule, then add these lines tomymodule.infoNow you need to tell Migrate about these new fields. The code in comment #1 is how Migrate Extras tells Migrate about the Location type, so you just copy this code into your own implementation in your own module, and add
phoneandfax.In
mymodule.module:This is a hack; it will override any future updates in Migrate Extras. But it works for now.
Now you can map your source phone and fax to the Location phone and fax fields. Here is a way that works, though I am not sure it's the best. (See #1118132: Working example of how to map source fields to a Location destination field? for more on this approach to mapping source fields to fax fields.)
This code goes in your Node Migration, outside the
_constructfunction. (E.g., in the examplebeer.incfor 6.x-2.0, you could put this after the closing bracket on line 341 but before the closing bracket of line 342.Hope this helps someone, and/or prompts a better solution. Again, this is a temporary hack until Migrate Extras supports these extra location fields dynamically.
Comment #3
mikeryanMigrate and Migrate Extras V1 are no longer supported. Location support for V2 is now consolidated to the following issue:
#943178: Implementation of Location support for Migrate Extras V2