I am looking for the option to have a feed delete all existing nodes created by the feed to be deleted before importing. This is especially important in the case that there is no unique identifier on the Source end.

The functionality should be there since there is the ability to delete all the feeds by visiting the delete items tab of the node with the feed attached.

I have found the code relevant to creating that delete page and form in feeds.pages.inc. Any help or guidance would be appreciated.

/**
* Render a feeds delete form.
*
* Used on both node pages and configuration pages.
* Therefore $node may be missing.
*/
function feeds_delete_tab_form($form, &$form_state, $importer_id, $node = NULL) {
if (empty($node)) {
$source = feeds_source($importer_id);
$form['#redirect'] = 'import/' . $source->id;
}
else {
$importer_id = feeds_get_importer_id($node->type);
$source = feeds_source($importer_id, $node->nid);
$form['#redirect'] = 'node/' . $source->feed_nid;
}
// Form cannot pass on source object.
$form['#importer_id'] = $source->id;
$form['#feed_nid'] = $source->feed_nid;
$form['source_status'] = array(
'#type' => 'fieldset',
'#title' => t('Status'),
'#tree' => TRUE,
'#value' => feeds_source_status($source),
);
$form = confirm_form($form, t('Delete all items from source?'), $form['#redirect'], '', t('Delete'), t('Cancel'), 'confirm feeds update');
$progress = $source->progressClearing();
if ($progress !== FEEDS_BATCH_COMPLETE) {
$form['actions']['submit']['#disabled'] = TRUE;
$form['actions']['submit']['#value'] =
t('Deleting (@progress %)', array('@progress' => number_format(100 * $progress, 0)));
}
return $form;
}

/**
* Submit handler for feeds_delete_tab_form().
*/
function feeds_delete_tab_form_submit($form, &$form_state) {
$form_state['redirect'] = $form['#redirect'];
$feed_nid = empty($form['#feed_nid']) ? 0 : $form['#feed_nid'];
feeds_source($form['#importer_id'], $feed_nid)->startClear();
}

Comments

MegaChriz’s picture

Category: Feature request » Support request
Status: Active » Fixed

I think this module provides the feature of deleting all items before import: https://www.drupal.org/sandbox/twistor/2187015

When looking at the issue queue of that module, it seems you already had found it.

nicxvan’s picture

Yes, I should have connected the two, in fact I think Twistor created the sandbox on IRC in response to this ticket.

Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.