Skip to main content
RSS Feed Importers

Programmatically create and trigger feeds importer

We met with a challenging requirement where we needed to create a feeds importer on node creation of particular content type. It’s like for ‘n’ number of nodes there must be an ‘n’ number of feeds importer.

For that I created a feeds importer which will be considered as the template. Whenever the node of specific content type is created, the template will be cloned and a new importer will be created.

The following code needs to reside in hook_node_insert() and will be used to clone the feeds importer:

// Pass the feed_importer_id which is already created
$template = feeds_importer('template');
// Get the exported code of already created feeds importer
$current_config = $template->config;
// Changed the name and description in configuration
$current_config['name'] = $node->title;
$current_config['description'] = $node->title;

// Start to create the new importer, argument will be a importer id for the new importer.
$new_importer = feeds_importer('ImporterId');
// Pass the configuration to the new importer.
foreach (array('fetcher', 'parser', 'processor') as $type) {
// Save the importer.

The above code will create a new feed importer with id ‘ImporterId’ on node creation.


Hi, what I was done is, first I was created a feed importer in UI which is considered as common feed importer. Whenever I created a node I cloned that common importer and created a new importer by using the above code. Simply what that code does means, It will clone the existing feed importer and created a new feed importer.