I am trying to migrate files into a custom filetype with a lot of custom defined fields. However they seem to be getting migrated in the document
filetype rather than into my custom created filetype.
I'm using the MigrateDestinationFile
as my destination like this:
$this->destination = new MigrateDestinationFile();
I've tried to map the type
like this answer suggested like this:
$this->addFieldMapping('type')->defaultValue('custom_file_type');
This solution doesn't work, when checking the mappable fields for the MigrateDestinationFile
there is no type
field specified so I think this is the reason why that solution doesn't work.
If some one could point me to an example of how to migrate into a custom file type that would be highly appreciated. Maybe I'm using the wrong destination
? Or did I miss something very obvious.
The other part of the migration doesn't matter for this question.
Apparently I had two issues. The first one being that when we created the file type we called it file
which for some reason you can't set as a migrate destination since it's already default in the MigrateDestinationFile
constructor (see code below).
From file.inc:544
/**
* Basic initialization
*
* @param array $options
* Options applied to files.
*/
public function __construct($bundle = 'file', $file_class = 'MigrateFileUri', $options = array()) {
parent::__construct('file', $bundle, $options);
$this->fileClass = $file_class;
}
Second issue was the mapping to the field bundle itself. I simply had to set the correct destination like this after re-creating the file type with a different name:
$this->destination = new MigrateDestinationFile('product_download');
After doing this the migrated files where created in the correct content type rather than the document
file type.