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)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

johnv’s picture

Please 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.

Michsk’s picture

Patch file.

Michsk’s picture

todo:
- keep existing alt
- keep existing title
- behavior with multiple files in one field.

Michsk’s picture

Coding standard thingy.

johnv’s picture

Status: Active » Needs work

@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()?

Michsk’s picture

@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.

Michsk’s picture

Here'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

Michsk’s picture

Michsk’s picture

Michsk’s picture

Think i need a break...

twistor’s picture

Category: bug » feature
Priority: Major » Normal
Status: Needs work » Closed (works as designed)

I'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.

Michsk’s picture

This 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.

Michsk’s picture

Issue summary: View changes

additional info

MegaChriz’s picture