It would be useful to add an option to mappings to taxonomy term reference fields (and perhaps entity reference fields too) to allow case-insensitive matching of incoming data.

In other words, if the CSV file contains 'FOO', and there's a term 'Foo', allow that to be matched up.

I can see where to change MigrateTaxonomyTermReferenceFieldHandler to make this possible, but I don't know enough about Migrate internals to see how to make that something that can be set as an option at the $this->addFieldMapping() stage.

Comments

mikeryan’s picture

You would add your new option to MigrateTaxonomyTermReferenceFieldHandler::fields(), like source_type and create_term. Then, in prepare(), reference it as $arguments['case_insensitive_match'] (or whatever you choose to call it.

joachim’s picture

Status: Active » Needs review

Thanks for the pointers :)

Here's a patch.

This'll need docs adding to http://drupal.org/node/1224042 as well; I can take care of that.

mikeryan’s picture

Status: Needs review » Active

No patch was attached.

joachim’s picture

Status: Active » Needs review
StatusFileSize
new1.35 KB

Oops. Here it is.

mikeryan’s picture

Status: Needs review » Fixed

Committed, thanks!

joachim’s picture

Title: allow reference values such as taxonomy terms to be case-insensitive » documentation: allow reference values such as taxonomy terms to be case-insensitive
Component: Code » Documentation
Assigned: Unassigned » joachim
Category: feature » task
Status: Fixed » Active

Thanks!

Converting this to a docs issue & assigning to me -- I'll add something about this to the docs page for this field mapper when the next release is out :)

joachim’s picture

Title: documentation: allow reference values such as taxonomy terms to be case-insensitive » allow reference values such as taxonomy terms to be case-insensitive
Component: Documentation » Code
Category: task » bug
Status: Active » Needs work
+++ b/plugins/destinations/fields.inc
@@ -366,6 +367,12 @@ class MigrateTaxonomyTermReferenceFieldHandler extends MigrateFieldHandler {
+      if (isset($arguments['ignore_case']) && $arguments['ignore_case'] == 'tid') {

Oops. Just spotted that the option should be compared to TRUE, not 'tid'!

mikeryan’s picture

Component: Code » Documentation
Category: bug » task
Status: Needs work » Active

OK, fixed the comparison.

dsim’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 1637292.migrate.taxonomy-term-ref-ignore-case.patch, failed testing.

mikeryan’s picture

Status: Needs work » Active

@silambarasan - I don't know what you're trying to do here, the patch has already been committed (and thus can no longer be applied). The issue remains active because joachim was going to update the docs.

dsim’s picture

Hi mikeryan,

I was confused with some other issue and did this. Sorry for this unnecessary action i did.

Thanks

mikeryan’s picture

Status: Active » Fixed

ignore_case is documented at https://drupal.org/node/1224042.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.