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.
I am using the migrate module to import full names that are in a single field in a CSV source file. The migration destination is a Profile2 field bundle that has a Name Field. Can you tell me how to migrate the full name text csv column, e.g. "Mr. John A. Smith, Jr." into the Name Field?
In the past I have used something like:
$this->addFieldMapping('profile2_name','first_name')
->arguments(array(
'family' => array('source_field' => 'last_name'),
));
which worked when the CSV file had separate first and last name fields.
Comment | File | Size | Author |
---|---|---|---|
#2 | name-1734922-2-migrate-support.patch | 2.01 KB | Alan D. |
Comments
Comment #1
Alan D. CreditAttribution: Alan D. commentedIf this is a one off, could you simple concat the name columns into one and do a one to one mapping?
Comment #2
Alan D. CreditAttribution: Alan D. commentedRight, I just had to do this myself from a single profile D6 field to a D7 user name field. This is the first time that I have used Migrate, so this may be wrong...
This is a best guess data mining from a single text field. If the fields were already separated, then this would be much easier.
In a nutshell, htmigrateUserMigration::prepareRow() simple tries to create an array of name components. All enabled components would be:
This was our migration class.
Out of the box, the Name field module has no support for the Migrate module, so I had to write this MigrateFieldHandler class to get it to work (see patch).
Comment #3
Alan D. CreditAttribution: Alan D. commentedPushed to dev. Reopen if you find any issues.
Comment #5
Jelle_SThis kind of clashes with #1463476: Migrate integration and #1468010: Name field support where a migrate field handler was added to Migrate Extras, where Migrate Extras seems to be doing a 'better' job (Following the Migrate standards) at it. Maybe this patch should be reverted again, and mention on the project page that if you want to use Migrate with this module, Migrate Extras should be used?
Comment #6
Dane Powell CreditAttribution: Dane Powell commentedInstead of re-opening old issues, let's continue the discussion at #2221717: Improve and de-dupe migrate handler