Active
Project:
Group
Version:
3.0.0-rc2
Component:
Documentation
Priority:
Major
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
9 Sep 2016 at 15:17 UTC
Updated:
17 Mar 2023 at 18:42 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
jzavrl commentedI'm assuming you have some sort of .csv or something that holds your content. I personally would go about this with some custom code that would import the content and the groups. D8 has the Migration module in core but I'm not sure how it works with Groups (although we are still dealing with entities so, in theory, it should work just fine), but this can also easily be achieved.
You could also go the other way around - importing the content and then assigning that content to the group. If it exists just reference it if not the first create it. This would remove the need for storing the ID in a field.
I'm not quite sure where are you at with this, so I might be talking nonsense to you right now :)
Comment #3
rachel_norfolkThanks - got me thinking!
I have a successful migration config that imports the groups now. Pretty simple entity migration, actually. Groups working well!
Now, the second thing is, on migrate of some nodes, to assign them to the correct group as they are migrated. That's the next challenge.
When its done, I'll write this up.
Comment #4
rachel_norfolkWow - it works! Actually, turned out to be a pretty simple job of reusing the same data source (json in my case) to now create group_content entities that attach the nodes created and the groups.
So, I was migrating the nodes in with
And then have another migration that looks at the same source:
Yes, all the data in this example is going to a single user. It’s a long story not related to the actual migration as such.
Oh - and petebarnett was a great help with providing a few pointers.
Comment #5
maxilein commentedComment #6
docans commentedHi. I have a similar issue
I want to Migrate Nodes that are in Drupal 7 into Drupal 8 Group content. What is the best approach or migration script to achieve this
Thanks
Comment #7
docans commentedComment #8
docans commentedI will like to importi my drupal 7 node content into a Drupal 8 Group Content that will be assigned to a group when it is imported. What is the best way to configure my YAML file for migration. Thanks
Comment #9
jzavrl commentedWithout going into too much detail and investigation and writing the .yml files, I would first go into creating the group content, which is irrelevant to the nodes. Then you would probably need two migrations based on the nodes from D7. First one would be the classic one that would be migrating the nodes. The second one would be the one creating the group content entity, which would reference the previously created group entity and also the previously migrated nodes via the migration_lookup plugin.
Like I said, I haven't gone into too much investigation to tell you what should the exact mappings be, but I hope I've provided you with some guidance.
Comment #10
docans commented@jzavrl Thanks so much for your imput.
I have been able to do the mapping and all that. My main issue now has to do with the destination plugin
I have a group type called "location". And inside the location group type i created a location called "Texas"
I will like to know how i should write my migration destination plugin to import my nodes from drupal 7 nodes into the "Texas" "group content for basic pages
The code below will get the migration into the group content
But how do i specify the content to be migrated into the Texas Location Group basic page content type.
Thanks
Comment #11
docans commentedThis morning i was able to get the first migration script done to import the Nodes from D7 to D8. My issue is how to now move the new nodes i brought in into group content of a specific group type using the "migration_lookup plugin" do you have any sample script i can look at.
Thanks
Comment #12
rachel_norfolkSounds like exactly what I posted above
Comment #13
docans commentedHi Rachel.
In my case i am not using a csv to import the data. I am using the process available at https://drupalize.me/blog/201604/custom-drupal-drupal-migrations-migrate... which uses the migrate upgrade and migrate plus tool
In my Group setup, I have a group type of "States" to which i create "Texas" as one of the groups, I also have a Location content type that i have made into a Location Group Content type.
To migrate from Drupal 7 location node to Drupal location 8 node, the migration script will look like this
However to migrate from Drupal 7 location node to Drupal 8 "Location Group content type node" for the "Texas" Group ,i want to know how to modify the destination parameters. I know it will look something like
What should i add to the destination plugin to direct the nodes being migrated to the ( Location Group content type ) for the ( Texas Group). and where would i use the "migration_lookup plugin" to achieve this
I hope this clarifies it better. Any help is appreciated.
Comment #14
docans commentedI have a few errors i want to share
when i run my migration script below
This is the error i got , is there anything missing that i did not do right
Comment #15
docans commentedHi Guys. Can anyone please point me in the right direction please
Comment #16
nxmassa commentedSo this doesn't solve the exact problem as it's written in the issue, but we were able to use this method to achieve our goal of getting content into a group after the migration. As detailed in this issue: https://www.drupal.org/node/2772623 the Groups module has a function called addContent() which relates nodes to groups. In a helper module, I added that function to a hook_node_insert() as follows:
With this in place we ran our migration and the nodes ended up in the correct groups.
It didn't work perfectly and it's not a great solution to this specific problem, but it helped us achieve our goals in the meantime.
Comment #17
deepak_123 commentedThank you @rachel_norfolk for #4. This saved my life :)
Here is are the two yamls i used for migrating the nodes with the first yaml, then associating them to the group with the second yaml.
For migrating nodes -
Then second migration for associating nodes to the groups -
Comment #18
rachel_norfolkYay! Glad it worked for you
Comment #19
taylormade415 commented@deepak_123 / @rachel_norfolk , where did you get the default
group_content_type_c09d09f4991abvalue? i've devel'd around the group_content and most variations of the machine names are more group groups-group_membership, or other combinations.Comment #20
dokumori commented@taylormade415 I assume you've already figured it out, but for those who are wondering how/where to find it:
It's in the DB - after adding some content to a group (in my case, I added group membership), see the content of the table `group_content`. Under the `type` field, you will see strings like `group_content_type_c09d09f4991ab`
Comment #21
moshe weitzman commentedThis was helpful to me as well. The re-saving that we do is super not performant in a migration scenario where you do so many entity saves.
Comment #22
moshe weitzman commentedHere is a patch that might be useful for folks who are migrating. If your process pipeline sets $entity->migrate = TRUE, then this patch will skip the resaving of groupContent during save and delete operations. That re-save is super slow. At end of all migrations, I suggest rebuilding node permissions. I *think* thats sufficient.
Comment #23
moshe weitzman commentedSorry, this one avoids a warning.
Comment #24
zcht commentedhas someone here migrated group 1.0 with the new subgroup module by chance? the structure of the subgroups has changed a bit, a new process plugin is needed now. now i am looking for a solution, maybe someone has already done something in that direction?
Comment #25
maebug commentedThe format of the value to use for the `type` field has changed since @dokumori's comment. It is now in the format [group_type_id]-[plugin_id]. For example, I have a group type that has an ID of `calendar` with the group content plugin for `event` nodes enabled. So my default value is `calendar-group_node-event`.
The process for figuring this out is the same: create example content and look at the `type` column of the `group_content` table in your database.
Example:
Comment #26
megha_kundar commentedBut this doesn't work with 3.x version of group
Can anyone guide me in migrating groups module
Please ?
Comment #27
megha_kundar commentedComment #28
mcortes19 commentedIn group v3 the group_content was changed to group_relationship, also it requires the plugin_id field, so your migration could look like this: