Closed ccchapman closed 1 month ago
Perhaps the contentData
needs to be passed through something that will "fill gaps in element" if maintainHierarchy
.
Hi, thanks for reporting and clear description! I raised a PR to adjust this.
Merged and this will be included in the next release.
Description
A feed mapping to an entry field which has the maintain hierarchy option enabled breaks the unchanged content feature. In other words, Feed Me will consider the element changed because the "new" content data only contains the leaf.
Expected output
Actual debugging output
For the time being, I have written a "hack" to workaround the issue.
Expand "hack"
```php Event::on( Process::class, Process::EVENT_STEP_BEFORE_ELEMENT_SAVE, function (FeedProcessEvent $event) { $canonicalElement = $event->element ->find() ->id($event->element->id) ->siteId($event->element->siteId) ->one(); $canonicalCategories = $canonicalElement->productCategory->ids(); if ( array_slice($canonicalCategories, -1) !== $event->contentData["productCategory"] ) { return; } $event->contentData["productCategory"] = $canonicalCategories; }, ); ```Steps to reproduce
Products
andProduct Categories
(the latter should be a structure)Product Category
with maintain hierarchy option enabledProduct Categories
section, the second one nested under the firstProducts
and setup mapping toProduct Category
fieldAdditional info