Skip to content

Commit

Permalink
Fixed #616
Browse files Browse the repository at this point in the history
  • Loading branch information
angrybrad committed Dec 14, 2020
1 parent 482e0db commit fec0819
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

## Unreleased

- Fixed a bug that prevent some feeds from importing. ([#786](https://github.com/craftcms/feed-me/issues/786))
- Fixed a bug that prevented some feeds from importing. ([#786](https://github.com/craftcms/feed-me/issues/786))
- Fixed a PHP error that would occur when importing into a custom field named `variants`. ([#616](https://github.com/craftcms/feed-me/issues/616))

## 4.3.3 - 2020-12-10

Expand Down
10 changes: 8 additions & 2 deletions src/elements/CalenderEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,18 @@ public function getMappingTemplate()
*/
public function init()
{
parent::init();

Event::on(Process::class, Process::EVENT_STEP_BEFORE_ELEMENT_SAVE, function(FeedProcessEvent $event) {
$this->_onBeforeElementSave($event);
if ($event->feed['elementType'] === EventElement::class) {
$this->_onBeforeElementSave($event);
}
});

Event::on(Process::class, Process::EVENT_STEP_AFTER_ELEMENT_SAVE, function(FeedProcessEvent $event) {
$this->_onAfterElementSave($event);
if ($event->feed['elementType'] === EventElement::class) {
$this->_onAfterElementSave($event);
}
});
}

Expand Down
14 changes: 11 additions & 3 deletions src/elements/CommerceProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,26 @@ public function getMappingTemplate()
*/
public function init()
{
parent::init();

// Hook into the process service on each step - we need to re-arrange the feed mapping
Event::on(Process::class, Process::EVENT_STEP_BEFORE_PARSE_CONTENT, function(FeedProcessEvent $event) {
$this->_preParseVariants($event);
if ($event->feed['elementType'] === ProductElement::class) {
$this->_preParseVariants($event);
}
});

Event::on(Process::class, Process::EVENT_STEP_BEFORE_ELEMENT_MATCH, function(FeedProcessEvent $event) {
$this->_checkForVariantMatches($event);
if ($event->feed['elementType'] === ProductElement::class) {
$this->_checkForVariantMatches($event);
}
});

// Hook into the before element save event, because we need to do lots to prepare variant data
Event::on(Process::class, Process::EVENT_STEP_BEFORE_ELEMENT_SAVE, function(FeedProcessEvent $event) {
$this->_parseVariants($event);
if ($event->feed['elementType'] === ProductElement::class) {
$this->_parseVariants($event);
}
});
}

Expand Down

0 comments on commit fec0819

Please sign in to comment.