2

I have two Feeds importers that need to run in a specific order. For example:

1) Importer 'Films' imports all the films showing at a cinema, creating 'film' nodes.

2) Importer 'Showtimes' imports the show times for each film, creating 'showtime' nodes.

Both importers are scheduled to run every day. 'Showtimes' must always run after 'Films' is fully imported, as it creates node references to film nodes.

Things I have tried:

Using Rules instead of Job Scheduler. I created a custom rules action using this code:

while (FEEDS_BATCH_COMPLETE != feeds_source('my_importer_id', $node->nid)->import());

I created a rule that triggers on cron with two actions: import films, import showtimes. This kind of works but when I look at the newly created nodes, showtime nodes are being generated before all the film nodes are created. So I guess rules actions aren't processed sequentially...?

Using Feeds Rules to chain one import onto another. Feeds Rules provides a 'after Feeds import' rules event.

So I tried creating a rule that triggers 'showtimes' importer (using my custom action above) after 'films' importer has run. But I ran into a problem applying a condition on the rule provided by the module. I'm not convinced this is the best method anyway.

Thanks

4

You've entered that territory where you would be better served by a custom module than trying to force Rules to do what you want.

If I were posed with this problem I would do the following:

  1. Create two CRON jobs one for each of the importers in a new module. See hook_cron().
  2. Turn off all of Feeds default importing for those feeds.
  3. Install Elysia Cron.
  4. Schedule your cron jobs with Elysia to run at appropriate intervals leaving enough time for the first to complete before running the second.
  5. For extra credit you could programatically check that the first import is complete before allowing the second to run.
0

I tried creating 2 different cron jobs for each of my importers. But what did you put into hook_cron for the importer? I put in the following:

$name = 'FEED_NAME';
$source = feeds_source($name);
$source->import();

But when I ran my cron job it only imported 2% and locked my feed importer... Any suggestions?

  • Did you have any news on this issue ? If you had any success please update this answer. – Jean-Michel Garcia Jun 25 '13 at 8:05
  • Quite late to this, but the answer lies in while (FEEDS_BATCH_COMPLETE != feeds_source('my_importer_id', $node->nid)->import());, or, in your case $node->nid shoudl be 0. The idea there is to run the import until the batch is complete – zerolab Jul 15 '14 at 22:14

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.