Here is my current setup:
Importer A
- Imports from a list
- Creates nodes with content (sometimes with an image)
- Does not update the nodes.
Importer B
- SelfNode processor, processes the node and imports remaining content
- Is allowed to update the nodes
- Importer B is used for multiple sites, so in xpath i am using quite some or's
- Sometimes a image is imported trough SelfNode, sometimes not (if not then it already has been importer trough importer A)
Problem
The issue here is that sometimes the image is a empty field when processing trough importer B. Which results in not passing the field to the $node entity. When feeds tries to update the node (entitySave($entity)), the image field is not in the $entity we send to entitySave, because it's an empty field.
It's the same when you for example unset the image field in node.module right before @1181. The image will be removed.
Solution
My guess is that we will have to tackle this with https://drupal.org/node/1107522. I would love to hear some suggestions.
Of course i can create a new node type for every imported article but that would be a hell when you want to add a new import. Or even worse when you want to add a new field to the imported nodes.
duplicates:
https://drupal.org/node/1809378#comment-7680415
(found some more tough)
Comment | File | Size | Author |
---|---|---|---|
#10 | feeds-empty-behavior-file-2049341-10.patch | 6.81 KB | Michsk |
#9 | feeds-empty-behavior-file-2049341-9.patch | 6.25 KB | Michsk |
#8 | feeds-empty-behavior-file-2049341-8.patch | 6.25 KB | Michsk |
#7 | feeds-empty-behavior-file-2049341-7.patch | 6.39 KB | Michsk |
#4 | feeds-empty-behavior-file-2049341-4.patch | 1.83 KB | Michsk |
Comments
Comment #1
johnvPlease check #1107522: Framework for expected behavior when importing empty/blank values + text field fix It contains a more general discussion for your problem. It also contains a patch for files.
Comment #2
Michsk CreditAttribution: Michsk commentedPatch file.
Comment #3
Michsk CreditAttribution: Michsk commentedtodo:
- keep existing alt
- keep existing title
- behavior with multiple files in one field.
Comment #4
Michsk CreditAttribution: Michsk commentedCoding standard thingy.
Comment #5
johnv@Lasac, this patch is a perfect example of my requirement here: #1107522-101: Framework for expected behavior when importing empty/blank values + text field fix.
But sometimes we DO want to replace the existing images with a new set.
It is a pity we need to do a node_load, because the default behaviour is to clear all existing data, as explained here: #1047894: Behavior when fields/columns are not in import file: do not clear field, but leave field untouched.
Can you extend the patch to use to all entity_types, using entity_load_single() or field_attach_load() instead of node_load()?
Comment #6
Michsk CreditAttribution: Michsk commented@johnv : The option to do a override is in there, we only use the currently used values if $value is empty, and $value is the new value fetched by the importer.
I will change the patch to work with other entities as well.
Comment #7
Michsk CreditAttribution: Michsk commentedHere's a much cleaner patch. Mappers do what they should so no entity loading, or that kind of stuff, since we already have those values in the FeedsProcessor. Every mappers callback will have a 'copy' of the old field value, so if needed we can use it.
Still to do is the alt and title. This patch also touches FeedsProcessor
Comment #8
Michsk CreditAttribution: Michsk commentedComment #9
Michsk CreditAttribution: Michsk commentedComment #10
Michsk CreditAttribution: Michsk commentedThink i need a break...
Comment #11
twistor CreditAttribution: twistor commentedI'm not sure when people started deciding this should be expected behavior.
What you need is either a Feeds Tamper plugin, a custom hook_feeds_after_parse() or a custom mapper.
This behavior is way too use-case specific to add to Feeds.
Comment #12
Michsk CreditAttribution: Michsk commentedThis is mainly based on all the 'help my data is removed after a blank field is imported' issues. Which is the case as well for images and is based on the framework issue (https://drupal.org/node/1107522). I am following the framework issue closely but it's getting scatterd and i think that you as the module maintainer maybe should open a issue and define what you think would be a best fit for all these 'my data is removed' issues. I am willing to help but i would really like to know how you would like to set this up.
I will start following https://drupal.org/node/2093651 as well, since i totally agree with that point of view.
Comment #12.0
Michsk CreditAttribution: Michsk commentedadditional info
Comment #13
MegaChriz CreditAttribution: MegaChriz commented