Provide a node type plugin that permits the developer to specify which node types should be imported. The UserRoleFilter plugin at https://www.drupal.org/project/migrate_plus/issues/3057685 is a great example of the kind of thing desired.
Amended description to better match the work done:
Create a standardized method for filtering imported content. Use this method to create filtered source plugins.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | migrate_plus-filtered_node_plugin-3067902-9.patch | 3.7 KB | gbirch |
| #2 | migrate_plus-filter-nodetypes-3067902-2.patch | 1.8 KB | gbirch |
Comments
Comment #2
gbirch commentedPatch.
Comment #3
gbirch commentedComment #4
gbirch commentedComment #5
benjifisherI think this option is a very good idea. My only suggestion is that we think more generically.
For example, my current project requires me to migrate nodes with a minimum creation date. (Do not migrate really old content.) Maybe this is an edge case that should be implemented with custom code. For the sake of discussion, assume not: then this is an option we might want to add in the future. If not this option, then I am sure there will be other restrictions that are common enough that we will want to add options for them.
I do not want to add a separate source plugin for every such feature request. Two reasons:
Adding an option for creation date is out of scope for this issue, but thinking ahead is in scope. If we simply change the name, then we can add further options in future issues. Instead of
class NodeTypeFilterandid = "d7_node_type_filter", let's make itclass NodePlusandid = "d7_node_plus", the "Plus" indicating that this is the version from the Migrate Plus module.Comment #6
heddn#3069776: SQL source plugins: allow defining conditions and join in migration yml seems like a good general solution to all of this.
Comment #7
gbirch commentedAgree with both comments. Has anyone taken a shot at a general purpose filter?
Presumably a simple configuration yaml could look something like this:
This could only handle a simple list of ANDed conditions, but it would be a decent start.
Comment #8
gbirch commentedOr, say something more flexible like this:
Which would translate to: (uid IN (2,3) OR changed > timestamp) AND (created > timestamp1 AND created <= timestamp2)
Comment #9
gbirch commentedI have not provided an interdiff, as this is a new approach. The trait could also be used to create FilteredX plugins.
Comment #10
gbirch commentedSorry, I realize that I provided a FilteredNode plugin, rather than a FilteredNodeType plugin. If this approach seems viable, I'll open a new issue and upload all of the FilteredX plugins I've created, which are working well for me at present.
Comment #11
chi commentedd7_nodeplugin can process specific node type.Though it is not possible to process multiple node types.
I think writing complex SQL queries like this in yaml files will not improve developer experience. In this case I would rather consider creating a custom source plugin that is suited to the needs of the project.
Comment #12
gbirch commented@Chi, thanks for looking at it. I admit that I have difficulty imagining that anyone would rather write a custom plugin with a custom query if they could just have a quick YAML file, but you may be right. That being said, it's not like this would prevent them from doing so.
Comment #13
gbirch commentedComment #14
chi commentedAnother issue here is that the annotation relies on table alias
nwhich is kind of internal thing. So that the alias now must be considered as part of public API and should be never changed.Comment #15
heddnThe great gitlab migration is upon us! This is now a duplicate of https://gitlab.com/drupalspoons/migrate_plus/-/issues/150. Please provide any comments from here, over there.