1

I'm working with Feed Me to run several feeds, bringing in multiple Entry types. I need to do some additional preparation work via an EVENT_AFTER_PARSE_FEED handler, which works well when I only have a single feed, but fails when I add a second feed.

I want to run the event handler for Feed A, but not for Feed B: Is there a simple way of specifying the feed when registering the event handler, or querying the event name inside the event handler?

3

it seems parse feed event only provide url and response. i don't know about specifying additional data for feed but some other solutions are:

  • add feed name as query string to feed url (if it is url and you have have control over it) and parse url on EVENT_AFTER_PARSE_FEED to detect feed name
Event::on(DataTypes::class, DataTypes::EVENT_AFTER_PARSE_FEED, function (FeedDataEvent $event) {
   $url = parse_url($event->url);
   $path = $url['path'];
   $query = $url['query'];
 });
<?php
use craft\feedme\events\FeedProcessEvent;
use craft\feedme\services\Process;
use yii\base\Event;
Event::on(Process::class, Process::EVENT_BEFORE_PROCESS_FEED, function(FeedProcessEvent $event) {
    if ($event->name == 'feed A') {
      foreach ($event->feedData as $key => $data) {
        $event->feedData[$key]['title'] = 'item' . $key; //changing data attribute of each data
      }
    }
});
?>

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.