3

I am setting up a drupal migration where the destination node contains a multi-value taxonomy term_reference field, called 'field_features'. The machine name of the drupal taxonomy vocabulary of the field is called 'voc_features'.

My field mapping for this field is configured like this:

$this->addFieldMapping('field_features:create_term')->defaultValue(true);
$this->addFieldMapping('field_features:ignore_case')->defaultValue(true);

//i don't have tid's in the source, so i leave the source_type for what it is
$this->addUnmigratedDestinations(array('field_features:source_type'));

//i link the drupal vocabulary to the multivalue field.
$this->addFieldMapping('voc_features', 'field_features')->separator('|');

The terms are added in the 'voc_features' vocabulary, but not in the 'field_features' field.

When i add the field mapping like i do with all the other fields:

//my source fields have the same name as my destination fields
$this->addFieldMapping('field_features', 'field_features')->separator('|');

i get the following error:

strtolower() expects parameter 1 to be string, array given File ...\sites\all\modules\migrate\plugins\destinations\fields.inc, line 402

Other single value term_reference fields import just fine. What am i missing?

4
+50

Yes. The migration of term doesn't allow to migrate multi-value. You have to process the source ahead.

  1. Create a new migration and import the data to terms of vocabulary named 'voc_features' at first.
  2. Add a dependence to your current migration using previous migration. Such as $this->dependencies = array('MigrateXXXMigration');.
  3. The field mapping should be like this,$this->addFieldMapping('field_features', 'Features')->arguments(array('source_type' => 'tid'));
  4. In the function prepareRow($row), you should prepare the Features field and put it into your $row variable. $row->Features=array(tid1,tid2,tid3);. The 'tid1','tid2' and 'tid3' should be replace the live tid from your term tables.
  • Have you managed to do this with the :ignore_case argument set to true? – jan May 19 '14 at 13:29
  • Is there an issue open about this? Having to do this amount of parsing makes migrate framework a lot less useful. – aaronbauman Jul 21 '14 at 19:39
0

Looking at the code for migrate module it seems to be a bug in the module.This issue happens when ignorecase is set to true while migrating multivalue fields. You may want to open a new issue in ALB migrate module.

0

I'm working on a migration also at the moment. I agree with Tony that you could write something using prepareRow() that would achieve what you want . Could you post your full extension class of RcnMigrateMigration, I'll see if I can make any sense of it.

  • I managed to get the migrate up and running with a separate migration for the terms first. However i did not use tid as source_type. This wasn't needed. I also didn't use the prepareRow() for this. I just used the 'separator' argument in addFieldMapping(). – jan May 20 '14 at 11:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.