0

Migration of content from Drupal 7 to Drupal 10.

I described the migration configuration in yml files separately for each content type and for each vocabulary, imported them, and executed the migrations. However, in each configuration, I did not specify id: id in the process section so that each piece of content or term would receive a new ID in Drupal 10, rather than the one it had in Drupal 7.

Now, I've migrated the URL aliases. For example, for the term "Apparel" I see:
Alias: /category/apparel
System path: /taxonomy/term/6018

However, there is no term with id=6018 because that was the ID for the term in Drupal 7. Now it has a completely different ID, which was generated during the migration. If I open the page /category/apparel or /taxonomy/term/6018, I see "The requested page could not be found."

Could you please advise what I need to write in the URL alias migration configuration so that the 'System path' ends with the new IDs as they are in Drupal 10?

id: upgrade_d7_url_alias
migration_tags:
  - 'Drupal 7'
  - Content
migration_group: migrate_drupal_7
label: 'URL aliases'
source:
  plugin: d7_url_alias
  constants:
    slash: /
process:
  path:
    -
      plugin: concat
      source:
        - constants/slash
        - source
  alias:
    -
      plugin: concat
      source:
        - constants/slash
        - alias
destination:
  plugin: 'entity:path_alias'
migration_dependencies:
  required: {  }

1 Answer 1

0

You could write a custom process plugin that uses the "source" value ("/taxonomy/term/6018") as input and returns the D7 TID ("6018"). You can then use the result as input for the migration_lookup plugin to find the D10 TID in your taxonomy term migration. And finally use the concat plugin to glue everything together in order to get the D10 source path.

The custom process plugin could look like this:

<?php

namespace Drupal\tic\Plugin\migrate\process;

use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Row;

/**
 * Tid.
 *
 * @MigrateProcessPlugin(
 *   id = "tid"
 * )
 */
class Tid extends ProcessPluginBase {

  /**
   * {@inheritdoc}
   */
  public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
    $explode = explode('/', $value);
    return $explode[3];
  }

}

The migration yml could look like this:

  _d7tid:
    plugin: tid
    source: source
  _d10tid:
    plugin: migration_lookup
    source: '@_d7tid'
    migration: thenameofthetaxonomytermsmigration
  path:
    -
      plugin: concat
      source:
        - constants/path_to_taxonmy_term # this should be "/taxonomy/term/"
        - "@_d10path"

Your Answer

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

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