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.
I am working on a D7 -> D7 migration (they want a clean start as they are re-defining many entity/field structures which is why they are migrating D7->D7).
The legacy D7 site uses D7 core Image fields. The new site users Media Module/File fields and File Entities. Any idea of the best way to migrate these fields?
Currently my code looks like:
<?php
// This example is migrating a D7 taxonomy to a D7 content type
// There is one D7 Image field in the source taxonomy that needs migrated to a D7 File field in the destination node)
class TaxonomyExampleMigration extends DrupalTerm7Migration {
public function __construct($arguments) {
$arguments = array(
'description' => t('Migration of legacy Example taxonomy terms to nodes.'),
'source_connection' => 'xxxx',
'source_version' => 7,
'source_vocabulary' => 'example',
'destination_vocabulary' => 'example',
);
parent::__construct($arguments);
$this->machine_name = 'TaxonomyExample';
$this->destination = new MigrateDestinationNode('example');
// Key Mappings
$this->map = new MigrateSQLMap($this->machineName,
array(
'tid' => array('type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
)
),
MigrateDestinationNode::getKeySchema()
);
// this does not work
$this->addFieldMapping('destination File field here','source D7 core image field here');
...
?>
Thanks for your help!
captaindav
Comments
Comment #1
mikeryanMigrate media file entities just like regular file entities in their own migration, using DrupalFile7Migration. Then you should be able to simply map the field using a file_class of MigrateDestinationFid. See the documentation on file migration at https://www.drupal.org/node/1540106.
Comment #2
mikeryan