I am attempting to migrate data from MSSQL into Drupal 6 using the Migrate module. In the legacy database that I am importing, there is taxonomy data that has extra fields that I want to migrate in, so I have installed the Term Fields module to hold the data related to the term. I'm not sure how to get the other data into the term_fields_term table.

In Migrate UI, I see a warning that one of the destination fields isn't being mapped.

I tried to address this with a class that extends MigrateDestinationHandler (modeled off the FlagDestinationHandler class in migrate_extras) and implements the fields() method, and added this class as a dependency, but it didn't seem to make a difference.

Can anyone give some pointers?

Comments

ebeyrent’s picture

It looks like the easiest way to accomplish what I am trying to do is to implement the complete() method in my Migration class, and use the Term Fields api to create the new records.

  /**
   * Completion method for inserting or updating supporting data for the term object
   * into the database.  This method create/updates records for the term data, so 
   * legacy data can be maintained.
   * 
   * @param stdClass $term - The term object that was created
   * @param stdClass $row - The current source row from the migration sequence
   */
  public function complete(stdClass $term, stdClass $row) {
  	// Data structure to hold the additional legacy field mappings
  	$values = array(
  	  'original_name' => $row->category,
  	  'teaser' => $row->teaser,
  	  'legacy_id' => $row->id,
  	);
  	
  	// Load the term and associated data
  	$term_data = term_fields_get_term($term->tid);
  	
  	// Determine whether to do an insert or update
  	if(!$term_data->legacy_id) {
  		term_fields_term_create_record($term->tid, $values);
  	}
  	else {
  		term_fields_term_update_record($tid, $values);
  	}
  }

Is there a better way?

drewish’s picture

Creating a MigrateDestinationHandler that adds the field should be the right way to do it. Could you post that code?

drewish’s picture

Oh, okay for the destination handler to work you'd need to have a migration that had terms as a destination. Then have another migration that creates nodes that depends on the term migration. Then you could reference the term migration on the field mapping by calling the sourceMigration().

moshe weitzman’s picture

Should we add any more tests for backend or --pipe? Even if we stub them out as TODO that would be helpful.

moshe weitzman’s picture

oops - posted to wrong issue. sorry

mikeryan’s picture

Title: Migrating terms and related data » Support for Term Fields
Project: Migrate » Migrate Extras
Component: Documentation » Miscellaneous
Category: support » feature

Support for contrib modules like Term Fields goes into the Migrate extras module.

mikeryan’s picture

Title: Support for Term Fields » Migration support for Term Fields
Project: Migrate Extras » Term Fields

These days, migration support for contrib modules should go into the module in question.

b-prod’s picture

Status: Active » Closed (won't fix)

If somebody provides a patch against Term Fields module to add such functionality, I could port it in a future release. So only if you suggest a patch for review, you are welcome to reopen the issue.

But I will not work on that, since there will not be more developments on Term Fields module, but only maintenance for bug fixes.