Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
For the Drupal 7 version, we should add a url.migrate.inc file that includes url_migrate_api() and a migration field handler for url fields.
Comment | File | Size | Author |
---|---|---|---|
#15 | Screen Shot 2020-01-18 at 9.48.27 PM.png | 28.54 KB | jas1988 |
#6 | 1778224-migrate-support-moved-hook_migrate_api.patch | 2.81 KB | frega |
#2 | 1778224-migrate-support.patch | 2.46 KB | hart0554 |
Comments
Comment #1
Dave ReidComment #2
hart0554 CreditAttribution: hart0554 commentedHere's a patch for basic Migrate field handler. Please forgive any newb mistakes.
Comment #3
Dave Reid@hart0554: Thank you very much for getting this started and providing a patch!
It looks like we'll want to declare this as a 'field handler' in url_migrate_api due to the recent changes in Migrate: https://drupal.org/node/1824884. The prepare callback seems much more complex than I had thought it would be. I'll double check if we can't do something simpler.
Comment #4
Dave ReidActually I think we don't even need to write our own Migration handler anymore with the recent 2.6 changes.
Comment #5
DrupalGideonI'm not getting this to work fully with Migrate 2.6 RC1. I'm getting the URL part migrated across absolutely fine but the title doesn't work.
It wants to migrate to the following destination fields -
I'm ignoring the 'attributes' as they seem to be blank but the title is not working.
I have my content type set to allow Unlimited values of URL links and I've passed single values, arrays, strings with a separator and all work for the URL part but not the title.
I can force a fixed value into the DB but not the migrated values. For now I think i'm going to have to do some extra processing in the
prepare
function to get the values into my new entity.Comment #6
frega CreditAttribution: frega commentedCould not get migrate-7.x-2.6 to work out of the box. Rerolled patch from #2, moving url_migrate_api (hook_migrate_api) to the url.module file. Works for me w/ current stable (migrate-7.x-2.5).
Comment #7
frega CreditAttribution: frega commentedSetting to needs review.
Comment #8
progpapa CreditAttribution: progpapa commentedSeems to be working for me out of the box with migrate-7.x-2.6.
This is the relevant part of the code:
Haven't tried with attributes, though.
Comment #9
jas1988 CreditAttribution: jas1988 commentedI have done migration from 7 to 8 and my content type is having url field. But this is missing in Drupal 8 content type after migration. Please suggest how to make possible to migrate url field of content type to 8. Thanks!
Comment #10
heddnIf the field doesn't just migrate on its own then you'll you need to create a custom field plugin for the url field type for D7. This should be added to a custom module that you create. See https://api.drupal.org/api/drupal/core!modules!link!src!Plugin!migrate!f... as an example of how this was done for the more mainstream link field.
Comment #11
jas1988 CreditAttribution: jas1988 commentedThanks for reply! I am very new to custom migration for 7 to 8 of url field of this kind. It will be very helpful if you can link some documentation links (I tried to search lot but unable to find solution ) so that I can read and understand more to migrate data and revision data of this field . Please suggest !
Comment #12
heddnhttps://www.drupal.org/docs/8/api/migrate-api/migrate-destination-plugin...
Comment #13
jas1988 CreditAttribution: jas1988 commentedThank you @heddn !! I am able to migrate url field data from 7 to 8 :
Plugin code used is below:
Comment #14
rafaticarte CreditAttribution: rafaticarte commentedHi,
Where have I put the code plugin?
Thanks.
Comment #15
jas1988 CreditAttribution: jas1988 commentedHi, you just need to place custom module having above plugin code. Change your field name etc (screenshot for details)