I'm a bit at the end of my rope in trying to get file fields to show up as possible destinations for my Media module migration. I have Media 7.1.x installed because as best I can tell, that must be the version that Migrate Extras was supporting. I'm trying to import files into the Other file type, so I have the following:
$this->destination = new MigrateDestinationMedia('other');
$this->map = new MigrateSQLMap($this->machineName,
array(
'id' => array(
'type' => 'int',
'length' => 11,
'not null' => TRUE,
'description' => 'File ID',
'alias' => 'f',
),
),
MigrateDestinationMedia::getKeySchema()
);
Unfortunately I cannot get the field I added to the Other file type to show up as an available destination field in Migrate UI. Any help on what I'm doing wrong here, or even a code snippet where someone has successfully done a media migration (for files, not youtube or anything fancy like that), would be greatly appreciated!
Update: I'm most of the way there, but my fields still aren't coming in. Here is the array I created:
I create a $row->fields_array that looks like:
[fields_array] => Array
(
[0] => Array
(
[field_doc_public] => 1
[field_testing_testing_testing] => UE2_3009.pdf
)
[1] => Array
(
[field_doc_public] => 0
[field_testing_testing_testing] => UE2_3009.doc
)
)
I really only need the field_doc_public field to be filled in, but I added field_testing_testing_testing to test as you might guess from the name. The field machine names are field_doc_public
and field_testing_testing_testing
.
The code in the actual migration looks like:
$this->addFieldMapping('field_doc_pub_files', 'file_source_file');
$this->addFieldMapping('field_doc_pub_files:file_class')
->defaultValue('MigrateEntityFileUri');
$this->addFieldMapping('field_doc_pub_files:fields', 'fields_array')
->description(t('Populate the fields.'));
$this->addFieldMapping('field_doc_pub_files:destination_dir')
->defaultValue('private://pub_docs');
$this->addFieldMapping('field_doc_pub_files:destination_file', 'file_dest_filename');
$this->addFieldMapping('field_doc_pub_files:file_replace')
->defaultValue(MigrateFileBase::FILE_EXISTS_REUSE);
$this->addFieldMapping('field_doc_pub_files:preserve_files')
->defaultValue(FALSE);
$this->addFieldMapping('field_doc_pub_files:display', file_public);
Any help on that last little push over the finish line would be greatly appreciated. (Note: no destination for the fields shows up in Migrate UI either)