2

I have defined custom entity using Drupal console. the entity have extra columns defined to store field data from D7 nodes migrated instead of having entity fields.

I am using Migrate tools and Migrate plus modules and created migration group defined as below:

id: phases
label: Phases nodes migration
migration_group: phases
deriver: Drupal\taxonomy\Plugin\migrate\D7NodeDeriver

source:
  plugin: d7_node
  node_type: phase

destination:
  plugin: entity:phase_entity

process:
  id: nid
  type: 
plugin: default_value
default_value: phase
langcode: language
name: title
user_id: uid
changed: changed
created: created

migration_dependencies: { }

The migration group listed under admin/structure/migrate But no import action execute.

I have tried to import with basic fields only but nothing happens.

I searched a lot but no results even examples, I did created destination plugin to save the entity but I don't know how to.

Do I have write some code? where to write it or where docs for that part?

Does Drupal migration not work for custom entities at all so I have to look for another solution?

Any help will be appreciated, Thanks in advance.

3 Answers 3

2

It looks like you're very close. Is your entity called "phase" or "phase_entity"? If it is "phase", then you should adjust that under destination. Here is what I would recommend:

id: phases
label: Phases nodes migration
migration_group: phases    
source:
  plugin: d7_node
  node_type: phase
destination:
  plugin: entity:phase
process:
  id: nid
  type: 
    plugin: default_value
    default_value: phase
    langcode: language
  name: title
  user_id: uid
  changed: changed
  created: created
migration_dependencies: { }
4
  • plugin: entity:{custom entity} not working at all May 28, 2018 at 22:25
  • 1
    @MohammedGomma - It works on Drupal core 8.5.3, migrate_plus 8.x-4.0-beta3, and migrate_tools 8.x-4.0-beta3. What versions of core, migrate_plus, and migrate_tools are you using?
    – H M
    May 29, 2018 at 22:43
  • Is this supposed to work? Same problem here? Are there existing issues on this subject? I have custom base fields but they don't ever get a value, although fields attached to the custom entity will get their values migrated. Aug 12, 2019 at 23:02
  • I figured it out and documented here: drupal.org/project/migrate_plus/issues/3074439#comment-13219505 Aug 13, 2019 at 1:35
1

I did some research and found reviews that entity:{custom entity} is not working.

There exist table destination plugin help migrate directly to DB tables.

The plugin have some issues but there exist patches here

0

When migrating data, I usually export all of the relevant data into CSV format, and then use a Python script (you can use any script, of course) to format the data into the new Drupal site format, and then post it in using D8's REST server. The main downside is that you have the overhead of HTTP requests, but I have done this with some success for moderate-to-large projects.

If you would like, I can give you some example code. Mainly, you are looking to authenticate with the REST server, and then systematically upload one content type at a time, and ideally record the newly posted entity's info as you may need to to set up references for content uploaded later.

However, if you want to go through the normal import route, another user may post a solution. This is my own workaround to the issue, and while it works it doesn't address how to use the Migrate modules.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.