Maybe I'm understanding it all wrong, but if you define a target that points to a field that is not called like the target you need to specify "real_target" to notify feeds the correct field to import, but then you also need to set the correct field with a substr or similar techinique to get the real name of the field imported.

I'm attaching a patch to pass the real target to the target callback if it's defined instead of the $mapping['target'] that may or may not be the right field to import.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pcambra’s picture

Status: Active » Needs review
FileSize
1.31 KB
pcambra’s picture

Crossposting in #1183440: Multilingual Feeds - Make field import language-aware, "probably the best solution is to pass the entire $targets array to the callbacks so they have much more information and flexibility to do their things instead of just the target name"

pcambra’s picture

Here's the patch with the $mappings array passed to the callback target functions so as to be able to expose extra properties like the real_target or even the language from external modules.

pcambra’s picture

Status: Needs review » Closed (works as designed)
FileSize
1.31 KB

Ok, figured out, patch in #3 makes no sense because you can get the mappings anyways with $source->importer->processor->config, sorry for the confusion.

I'm reattaching patch in #1 for clarity, I don't think that each target callback have to do a substr or similar to get the real target field when it is defined in the mapping itself.

pcambra’s picture

Status: Closed (works as designed) » Needs review
js’s picture

I must be doing something wrong. real_target is not working for me after the recent update.

It was working fine when I applied the patch in the older "dev".

In my_module_set_target() $target has the value of the $targets key and not "real_target", so obviously in my case $entity->$target['und'][0]['value'] does not work.

I would appreciate help. Should I just be using the field name as the $target key?

colan’s picture

Status: Needs review » Closed (works as designed)

This is no longer necessary for #1183440: Multilingual Feeds - Make field import language-aware. (I'm about to post an update over there with all of the work I've been doing to get it up & running.) If anyone else actually needs this for anything, please reopen.