1

I have the following Module loaded into my system, following the Event's on the FeedMe documentation I've implemented the following to change the slug per entry import but unfortunately, it's returning a strange error that I just can't fix.

Here's the module:

<?php

namespace modules;

use Craft;

use craft\feedme\base\Element;
use craft\feedme\events\ElementEvent;
use craft\feedme\services\Process;
use craft\feedme\events\FeedProcessEvent;


use yii\base\Event;

use craft\helpers\ElementHelper;
use craft\elements\Category;
use craft\elements\Entry;

class TitleChangerModule extends Module
{
    public function init()
    {
        parent::init();
        Event::on(
          Process::class,
          Process::EVENT_STEP_BEFORE_ELEMENT_SAVE,
          function(FeedProcessEvent $event) {
            switch($event->feed['name']){
                case 'merchants':
                    $element = $event->element;
                    $element->slug = ElementHelper::createSlug($element->title.' '.'Coupon Codes & Promo Codes');
                    break;
            }
        });
    } // Close Public Function
} // Close Module Off

It returns the following error on each import via the feedme logs.

Class 'craft\feedme\base\ElementEvent' not found - Element.php: 58

2

There is a PR to fix this, in the meantime, you can add use craft\feedme\events\ElementEvent; at the top of vendor/craftcms/feed-me/src/base/Element.php

| improve this answer | |
  • Thanks Oli, annoying little bug this one! – JMKelley Jun 24 '19 at 9:57

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.