We have a content type that up until today was 100% driven by a feeds importer on a D7 site from an XML file (from a third-party system). This importer ran nightly and was set to "Unpublish non-existent nodes" which worked perfectly to remove items not available anymore.

Due to a business needs change we now need to manually create a couple of nodes of this specific content type and we don't want the importer to unpublish these specific nodes. Modifying the third-party system is not an option so the only possibility that we've come up with is to create a local file (CSV/XML/whatever) and create a new importer to run after the original importer to re-publish them.

We could also locally consume the original file and merge it with our custom node list but this seems like more things could break.

Is there another solution to this problem that we're missing?

  • Hi Chris, The answer to your question depends on a couple of things. Which processor are you using to import data? What is the "target" of the field/property set as unique in your processor configuration? – Captain Pants Mar 15 '16 at 17:16
  • @CaptainPants, we're using the Node processor and we are uniquifying on a text field (program_id) that's enforced by the field_validation module. – Chris Haas Mar 15 '16 at 18:16
  • I don't believe that the Node Processor has the ability to unpublish feeds results that it no longer finds from its feeds source. I can only assume that this unpublish functionality is custom and runs when you trigger an import. Am I correct in this assumption? – Captain Pants Mar 15 '16 at 20:37
  • No, that's built in. In my Node processor Settings I have Action to take when previously imported nodes are missing in the feed with three options, Skip non-existent nodes, Delete non-existent nodes, and Unpublish non-existent nodes. The last one is what we are currently using. – Chris Haas Mar 15 '16 at 21:01

You seem to be using a version of feeds that is fairly recent (perhaps version 7.x-2.0-beta2). Having said that, the process function of the FeedsProcessor class is fairly inflexible when it comes to modifying the list of imported nodes that it wants to clean out of Drupal, in that it does not provide a hook to modify that list.

Having said that, your best bet is probably to extend the FeedsNodeProcessor class and only override the initEntitiesToBeRemoved function to then exclude "potentially unpublished" node ids from $state->removeList. You'll need to determine how all of the nodes from $state->removeList were created.

How you determine a manually created node from a feeds imported node is up to you but I would recommend querying the feeds_item table. If a node's nid is not found in that table then it's safe to assume that the node was manually created.

| improve this answer | |
  • Thanks Captain! Yes, that's the version that we've been using. I'll poke through this tomorrow but this helps a lot! – Chris Haas Mar 15 '16 at 22:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.