Ok, so this is the relevant code in the service processing the feed, where the stepBeforeElementMatch is being called:
// Fire an 'onStepBeforeElementMatch' event
if ($this->hasEventHandlers(self::EVENT_STEP_BEFORE_ELEMENT_MATCH)) {
$event = new FeedProcessEvent([
'feed' => $feed,
'feedData' => $feedData,
'contentData' => $matchExistingElementData,
]);
$this->trigger(self::EVENT_STEP_BEFORE_ELEMENT_MATCH, $event);
if (!$event->isValid) {
return;
}
// Allow event to modify variables
$feed = $event->feed;
$feedData = $event->feedData;
$matchExistingElementData = $event->contentData;
}
I have not tested this, but by the looks of it, it should be enough to set the $event->isValid
to false
in your code after doing the necessary checks that you want.
Be aware that the $event->feedData
you are working on is an array representation of your feed data (converted from, XML, JSON or whatever). So you need to do your checks accordingly. At this point, Feed Me has not tried to match against potentially existing elements in Craft. Your example code basically assumes there's a field in the feed element with the name status
with the value false
. If that's not the case, you could do your checks on whatever you want, before a certain date, etc.
But if it is, something like this would be likely to work (again untested):
if($event->feedData['status'] == "false") {
$event->isValid = false;
}
If you're looking to skip based on some Craft element, you'd either need to query for it (basically doing some custom matching), or use an event later in the process (I can help you out there too, but maybe it's easier in your case to skip it already here).