Hi,

Is it possible to access message returned by:

 while (FEEDS_BATCH_COMPLETE != feeds_source('my_feed', 0)->import());

So I could use returned string i.e. "There are no nodes." or how many nodes were imported/updated?

Currently I'm using drush eval and cron for feed imports, and I would like to uset those values in bash script, but thats not the case if I get it as php variable its fine for me.

Thanks in advance,

Comments

rolkos’s picture

I've found solution for this issue:
drupal_get_messages()

But it's not perffect. I suspect that if between import and drupal_get_messages() some script will set new message I will get that new message instead of feeds message.

MegaChriz’s picture

Status: Active » Fixed

If you have access to the FeedsSource object, you can get the statical information by calling the state() method on the FeedsSource object:

$state = $source->state(FEEDS_PROCESS);

This FeedsState object contains (among more) the following information:

  • created
  • updated
  • deleted
  • unpublished
  • blocked
  • skipped
  • failed

Example:

/**
 * Implements hook_feeds_after_import().
 */
function mymodule_feeds_after_import(FeedsSource $source) {
  $state = $source->state(FEEDS_PROCESS);
  drupal_set_message(t('@num_created items were created and @num_updated items were updated.', array(
    '@num_created' => $state->created,
    '@num_updated' => $state->updated,
  )));
}

Status: Fixed » Closed (fixed)

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