0

I want to have very specific control over the node update process for Feeds. Using hook_feeds_presave() I can stop a node from being updated with $entity->feeds_item->skip = TRUE; but how can I force a new node to be created.

If a node would otherwise update an existing node I want it to create a new node.

This is for Drupal 7.

Thanks!

0

You can make use of Entity::isNew function to check if the entity is new, and skip the setting of skip to true:

  if(!$entity::isNew()){
    $entity->feeds_item->skip = TRUE;
  }
  • Thank you for your answer but what I am trying to do is force a new node to be created if it would otherwise be a duplicate. So another words make it is_new. – Josh Nov 12 '18 at 16:54
  • 1
    if i understand, you want to create cloned node in update of node, for instance on update of node with nid = 2 it will create node with nid = 3 .? – berramou Nov 12 '18 at 17:14
  • Not exactly. Let's say I have it set that it updates nodes that match on ID in the Feeds UI. This would mean it would find nid = X and update that nid rather than creating a new node. I would like to interrupt this process and force a new node to be created rather than node X being updated. – Josh Nov 12 '18 at 17:58

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.