Closed (outdated)
Project:
Paragraphs
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
20 May 2014 at 17:10 UTC
Updated:
2 Jan 2026 at 16:15 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
derhasi commentedSo, there is the first patch, that provides a basic Handler for Paragraphs Item Entity and the Paragraphs field.
The patch provides the state of my latest commit in my github repo: d5fce366544a86f6f25907586fc1c49db1ab41db.
Comment #2
jeroen.b commentedThanks!
We are doing a project with migrate soon, in the project we also need to migrate paragraphs.
I will test this patch when we start migrating, most likely next week.
Comment #3
jeroen.b commentedI couldn't get the patch to work with Drupal make using beta4 (probably due to the added packaging information by Drupal), here's a version that works.
Comment #4
jeroen.b commentedNo problems so far. Will be merged in beta5.
Comment #5
daveianoFirst it´s very nice that you have written such a FileHandler for Paragraphs, thank you ;)
But I need a little help on this. How have I to use this in my Migration Class? Can you give a little Example?
Comment #6
jeroen.b commenteddaveiano, for the FieldHandler for Paragraphs you just return an array of paragraph entity id's.
Comment #7
daveianoyeah I have found out that, but the Paragraph Entities I have to create manually?
Comment #8
jeroen.b commentedYou can use the MigrateDestinationParagraphsItem class for that, I didn't try that yet though.
Maybe derhasi can write something about how to use it.
Comment #9
jeroen.b commenteddaveiano, I think you have to make a migration class that extends MigrateDestinationParagraphsItem.
Like "MyProjectParagraphsMigrate extends MigrateDestinationParagraphsItem" (register the class as MyProjectParagraphs in the hook_migrate_api()).
In that class you do field mappings to the paragraph entity like you normally would on the node.
Then in the node migrate you put something like:
$this->addFieldMapping('field_paragraphs', 'field_paragraphs')
->sourceMigration('MyProjectParagraphs');
Comment #10
ti2m commentedI can confirm that the patched worked for me, no problems so far. A basic example/some documentation would be nice though. IF I got it right, then one has to use two migrations, one for the paragraphs, one for the nodes that use the paragraphs.
My essential lines for the paragraphs import:
where field_pcf_content is my paragraphs db field and para_image_alligned_left_text my paragraph type.
In the nodes import I then used (as stated above):
I didn't extend 'MigrateDestinationParagraphsItem' though, both of the migrations extend 'Migration' directly.
Comment #11
derhasi commentedYeah, that's right. We could provide an example feature with an example migration, so it could become clear.
Comment #12
ti2m commentedI seem to be having an issue when updating paragraphs (e.g. with drush mi --update). A new revison of a the paragraph is always being created, which means I end up with a ton of old revisions which aren't used for anything anymore. Especially confusing when working with file entites, files are being referenced by "dead" paragraphs. As far as I can tell there is no way to revert a paragraphs revison by itself, or is there? So my question is if this is a bug or a feature, that I'm not aware of. By looking at the code it doesn't look like there is any way right now to avoid the creation of a new paragraph revision.
I looked at MigrateDestinationNode and checked how they handle updates. The latest vid is loaded for the given nid. So I did the same for paragraphs revision_id and everything seems to be working for me as expected. I can post the patch if anyone is interested.
Comment #13
jeroen.b commented@ti2m nice, please provide the patch so I can put the patch in a release!
Comment #15
jeroen.b commentedJust pushed this to dev, please test.
@ti2m, can you provide the patch?
Comment #16
meppapza commentedHey, I am getting the following error: Unable to create a paragraphs item without a given host entity.
What is a common cause for this?
My code: http://pastebin.com/s1DUck0m
Comment #17
ti2m commented@jeroen.b Sorry for the delay, here is the patch, just rerolled it against 7.x-1.x
Comment #18
jeroen.b commented@meppapza, this patch is only pushed to dev. If you want to try it without upgrading to dev, please apply the patch.
Thanks @ti2m, pushed to dev.
Comment #20
jeroen.b commentedComment #22
moonray commentedThe docs were never added. It's still not very clear how to implement migration for paragraphs.
Comment #23
adamzimmermann commentedHopefully this helps someone. I was able to piece this together with some of the examples above and some other random links.
Comment #24
bburg@Adamzimmermann Just curious what classes you actually did extend (or what classes did your parent classes extend)?
Comment #25
adamzimmermann commented@bburg I was migrating from XML, so I used
XMLMigration, but this should work with other base classes as well.Comment #26
jeroen.b commentedCould it be added to the documentation?
Comment #27
awasson commentedI'm circling around to see if there has been any new developments in configuring migrations for Paragraphs. Any news?
Comment #28
krisrobinson commented+1 Also looking for some sort of documentation on how to migrate D7 Paragraph -> D8 Paragraph migration... quite frustrating. :)
Comment #29
bburgI'm just copy pasting code from the project I worked on over a year and a half ago, so I may not be able to answer any specifics about the migration. "Frameworks" are what the content was referred to, that were becoming paragraph items. These were being migrated from D6 nodes to D7 paragraphs.
Here's my migration definition from hook_migrate_api() in my_module.migrate.inc.
This was merged with a standard set of arguments used across all/most migrations:
Constructor for FrameworkMigration.
This class' parent constructor also does a few things of interest that aren't necessarily related to Paragraphs specifically.
The addSource() mtheod.
I also wrote a custom query() method to set my connection data. This isn't specific to Paragraphs though, just a habit of mine.
Then defining your field mappings is just like any other migration. I haven't re-reviewed this thread to date. So I'm not sure if I am even providing anything new here.
Comment #30
mark.bennett commentedDoes anyone have any suggestions for this issue I posted in the Migrate issues?
https://www.drupal.org/project/migrate/issues/2950681
Comment #31
a_z_official commentedI'm still having difficulties with paragraphs migration from Drupal 7 to Drupal 7.
Actually, We have just rebuild our site cause the previous one was subsequently damage. There are dead entries in Database, Mismatch schema, and what not. so we have decided to migrate the required contents to a fresh D7 installation.
Everything whent well, except this paragraphs thing, we have a content type "news" where we are using a paragraphs field as the body, we use the paragraphs bundles as per the requirement, there are 3 bundles E.G. Text, Video, And Entity Referenced field to nodes.
Now what would be the way to get it work?
Thanks.
Comment #32
a_z_official commentedAnyone has done D7 to D7 paragraphs migration successfully?
Comment #33
bluegeek9 commentedUnfortunately, Drupal 7 is End of Life and no longer supported. We strongly encourage you to upgrade to a supported version of Drupal.