I am using Feeds to import events from a CSV. I do not have the image field mapped.

However, I do need to 'replace' the nodes as opposed to update since I need the new event dates/times to replace what is there.

The problem is that by using 'replace' it also deletes my image field, it doesn't just clear the field, it deletes the image itself. Meaning if other nodes reference that image (the FID), it is cleared.

IE:

Have an event type with Image (hello.jpg), Name (Hello World), Date (3/12/2018 03:00:00)

Running import (with a GUID) that updates events mapping Name and Date only --using replace. After update I would have

Image(NULL), Name (Hello World), Date (3/12/2018 05:00:00)

The image hello.jpg has been completely deleted from the files folder, the FID table, etc.

Does anyone have any suggestions, some code for a hook, etc, where I can tell feed importers to NEVER unset/remove a particular field on imports?

Any help or nudges in the right direction would be appreciated.

Comments

twistor’s picture

Status: Active » Fixed

Using the "Update existing" functionality will work just fine. Any field that has a mapping will have their field values replaced on update.

There was a bug that would cause some fields to not update correctly, but that has been fixed in the latest dev.

CLEE25’s picture

Thank you for your comment, however I really do need to use the 'replace' function, not the 'update existing' function.

My import consists of events that have multiple dates, the multiple dates are stored in a field collection.

If I simply 'update exisiting' then dates are 'added' to the event, not removed and replaced.

If I use 'replace' then the events are removed and replaced, but it also kills/deletes the image.

Which is why I am seeing if there is anyway to make that behavior stop. Some sort of hook or code that prevents a replacement for a certain field.

CLEE25’s picture

Status: Fixed » Active
twistor’s picture

That sounds like a bug in the Field Collection support.

You can use hook_feeds_presave(). See feeds.api.php. Perhaps, you can load the original image and re-assign it to the new entity.

This is backwards though, and it would still be better to comment on the field collection issue.

MegaChriz’s picture

Status: Active » Closed (fixed)

Question seems to be answered a while ago. In the current version of Feeds, data always gets replaced, never appended.