Closed (duplicate)
Project:
Migrate Plus
Version:
8.x-1.x-dev
Component:
API
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
11 Dec 2015 at 12:05 UTC
Updated:
3 Nov 2019 at 02:34 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
heddnPossibly we could use something akin to https://www.drupal.org/node/2181783, but a little more specific for term entity reference fields.
Comment #3
heddnComment #4
heddnThis is simply a WIP. Marking postponed, since we have two dependencies that need to land first.
Comment #5
heddn#2633428: Add a Case Sensitive Condition to Entity Query is no longer a dependency. D7 didn't do the case comparison in a SQL query, probably because it isn't possible there either. We'll have to retrieve results, then do the comparison in PHP. The getter issue is also seeing good progress.
Comment #6
heddnComment #7
jordanpagewhite commentedComment #8
jordanpagewhite commentedComment #9
ada hernandez commentedThis patch auto create a term reference record on the content migration if the term value doesn't exist.
Comment #10
heddnNo longer necessary.
No longer necessary.
We should provide the vid from configuration instead. And throw an exception if it doesn't provide one.
This is unnecessary.
Comment #11
ada hernandez commentedSorry, If this it's ok.
Comment #12
heddnThis isset check should happen before we grab the value from configuration. In case it isn't set...
Nit: spaces between // and the sentence.
Nit: Only a single period is necessary.
@@ -0,0 +1,123 @@
+
Nit: this can just be:
if (!Vocabulary::load($vid)) {And I guess we should create some unit tests for this.
Comment #13
mikeryanDoesn't #2642612: Create Entity Lookup & Generate process Base plugins solve this in a more general way?
Comment #14
heddnre #13, it does solve part of the problem. But it doesn't create a stub.
Comment #15
mikeryanBy "stub" you meant implicitly creating a term if none exists, of course (the word "stub" confused me for a minute since the patch does nothing with stubs).
I think the work in that issue could be leveraged here - at the very least derive from that class and let it do the lookup. I wonder to what extent the target entity creation could be generalized beyond terms?
Comment #16
heddnYes, I'm all for offloading the search to the other class. But then we'd want to make as few assumptions there as possible. I noticed you mentioned we'd want bundle, but we really don't need that for terms reference. We just need the destination vid. But making a default_value, "required" seems a little strong-handed. There's already a default value plugin. Use it instead.
Comment #17
mikeryanFor taxonomy terms, the vid is the bundle.
Comment #18
ada hernandez commentedWe've changed to abstract base class that does only query, and just in the plugin term_reference create the term if this don't exist.
A example of process.
Comment #19
esclapes commentedI have tried patch in #10. Applies clean and works as expected.
Raises a warning when
entity_typeis not set. Could useempty($this->configuration['entity_type'])instead.Thanks!
Comment #20
penyaskitoShouldn't this be solved by dependencies instead? If the taxonomy migration runs before the reference, this shouldn't be a problem.
Comment #21
heddnre: #20, that assumes this is a d2d migration where there is already a separate term migration. But in D7 contrib migrate and in my case on D8, I'm migrating in from CSV. There's 4 taxonomy reference fields on the node. I don't want to create 4 additional migrations. Ideally, I can read over the CSV once and insert all the term stubs at the same time as I'm creating the node. From an I/O perspective, CSV isn't all that performant. So reducing the number of times I have to process the same text file significantly cuts down on processing time.
Comment #22
esclapes commentedNot sure, but I guess for that you would need a normalized source of terms and references.
In my use case I source from a csv where terms are just strings in a column for each article. Being able to do a lookup and create the term when it does not exists is very handy.
Comment #23
ada hernandez commentedThanks for your comments,
#19. I did your suggestion.
Comment #24
ada hernandez commentedComment #25
heddnCleanup after making some updates to #2642612: Create Entity Lookup & Generate process Base plugins
Comment #26
mikeryanAs I commented at https://www.drupal.org/node/2642612#comment-10812080 - why have a model requiring a separate process plugin for every entity type?
Comment #27
heddnThis won't be necessary after #2642612: Create Entity Lookup & Generate process Base plugins is completed.
Comment #28
brooke_heaton commentedIf you came here looking for a working example but found a myriad of confusing historical comments, you need to do this (assuming that you are using a taxonomy reference field and that the vocabulary is 'category' for example).
If you are missing any of the following (plugin, source, entity_type, bundle, property), the import will fail.