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.
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.
Comment | File | Size | Author |
---|---|---|---|
#4 | 1183408_import_real_target-4.patch | 1.31 KB | pcambra |
#3 | 1183408-import_real_target-3.patch | 11.27 KB | pcambra |
#1 | 1183408_import_real_target.patch | 1.31 KB | pcambra |
Comments
Comment #1
pcambraComment #2
pcambraCrossposting 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"
Comment #3
pcambraHere'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.
Comment #4
pcambraOk, 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.
Comment #5
pcambraComment #6
js CreditAttribution: js commentedI 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?
Comment #7
colanThis 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.