Problem/Motivation

There are several situations in which it might be desirable to import deeper level refenced entities in one go.

When I want to import commerce products, I first have to import all media items, then all product variations and finally all products. That meens 3 different feed types and several feeds. This feels very unintuitive.

I am wondering if we can solve the above specific situations as a more generic issue by handling entity reference fields differently.

Steps to reproduce

As an example the explanation given in #3052350-5: Core Media module: Trying to map Image Alt, Caption & Photo Credit

Proposed resolution

Allow filling entity reference fields directly from the parent entity's feed mapping.

Remaining tasks

User interface changes

Idea; to avoid long lists, the mapping navigation might look more like search api's way of selecting an entity field.

API changes

Data model changes

CommentFileSizeAuthor
#3 MediaTarget.txt11.22 KBneograph734

Comments

Neograph734 created an issue. See original summary.

megachriz’s picture

Multilevel import would indeed be a cool feature to have and I agree that the current workflow is not intuitive.

For Commerce product and product variations I did experiment with a possible way to solve this issue by trying to introduce a subfeedtype + subfeedtype processor concept. But that experiment didn't go very well: I got overwhelmed by the complexity of that and I gave up.
See #2981190-9: Provide simple product (combined product + variations) feed importer default where I posted code that I made.

It could help if there is an example of how Migrate solves this issue of multilevel import, but so far I experienced that in Migrate you also have to import stuff separately (for example: one migration for files, one for paragraphs, one for nodes).

The code in the Media Feeds module also seems interesting. The concept of subtargets looks like a better approach than what I tried before with subfeedtypes.

neograph734’s picture

StatusFileSize
new11.22 KB

Thanks for your reply.
What I've proposed here is more in line with option 2 from #2981190-10: Provide simple product (combined product + variations) feed importer default.

I am not reallty sure if the comparison with migrate is a valid one. In my opinion a migration is a one-time import for all content. I do recall that since Drupal 8 this has changed a bit, but so far I've not had to perform a Drupal 8+ migration. Feeds importing appears to be a much more frequent (scheduled) operation.

This approach could potentially also solve the order issue described in #1529704: Determining order of scheduled feeds as well.

I am however not sure if the Media feeds module is the way to go. I've been trying to simplify that for a while already, but got stuck at the entity validation stage which is happenig outside of the target plugin. It felt simplification was needed because of the recursion happening. From the looks of it Media feeds was copied from Feeds Paragraphs, where such recursion makes more sense because one paragraph could contain another one. So Feeds Paragraphs feels like a better starting point then. I've however found it a bit hard to untangle...