I have a migration use case where I can't figure out a way to get along with:
I have a Drupal 7 site which shall be migrated to D8. I don't want to migrate the content 1:1 but rearange some things to better fit the D8 way.
In the old site there are products which have an "ingredients" field which is a reference to taxonomy terms. Additionally there are "griege" nodes which technically represent an ingredient but are not associated with the taxonomy vocabulary "ingredients". They have indeed the same title so could be mapped by string comparison.
Now I want to do the following:
- Import all "Griege" nodess from the old site and save them as "Ingredient" nodes
- Import all "Product" nodes to the new site
- Check if they have ingredients (taxonomy terms) assigned
- If so, search for "Ingredient" nodes in the new site (term name == Ingredient title) and attach them to the newly created "Product"
In short I want the assigned taxonomy terms to be converted into "normal" content entities.
What I did so far is to extend the Drupal 7 node source plugin by adding the following left joins within the query() method:
$query->leftJoin('taxonomy_index', 'ti', 'ti.nid = n.nid'); $query->leftJoin('taxonomy_term_data', 'ttd', 'ttd.tid = ti.tid');
My problem is that I don't know what to do with that information within the process plugin. I could return the correpsonding Ingredient ID but as it's an 1:N relation between Prdouct and Ingredient that would mean it would overwrite the array holding the product ingredients everytime I process a row.
I hope my problem is somehow clear... :/
Some general questions I have:
Is there a way to access the datasource (the D7 source database) within a process plugin? E.g. do a select on the old product (get all terms, do the lookup in the new DB and return an array of Node Ids)
Could my solution somehow involve the usage of a destiantion plugin (I haven't fully understood the usage of those I fear)?
Is there something completely different I missed out to do the job?
Many thanks in advance!