My requirement is to import nodes daily night after deleting all the contents in that node type.
I enabled the cron settings in feeds module as 1 day and tried to write hook_cron() to delete all nodes.
function my_module_cron() {
$results = db_select('node', 'n')
->fields('n', array('nid'))
->condition('type', 'ars', '=')
->execute()
->fetchCol();
if (!empty($results)) {
node_delete_multiple($results);
}
}
But the doesn't seems to be deleted. I think this might be because of the user access problem.
I also want to know will the delete occurs before re-importing. How to order the cron jobs or shall I run the import via code after deleting the nodes.