0

I'm trying to migrate private files (file migration), the problem is even I set file_replace to 'FILE_EXISTS_REUSE' the files are still duplicated (it adds _1 or _2, and so on.). Here is my mapping:

    $this->addFieldMapping('file_replace')
         ->defaultValue('FILE_EXISTS_REUSE');
    $this->addFieldMapping('preserve_files')
       ->defaultValue(FALSE);

Please help!

  • Are you sure you should not use $this->addFieldMapping('file_replace')->defaultValue(FILE_EXISTS_REUSE);? – kiamlaluno Dec 16 '15 at 12:13
  • I've already tried that, but still no good. – japhfortin Dec 16 '15 at 12:20
1

This solved it for me. The documentation at this link has been updated to show that you need to use the class prefix:

$this->addFieldMapping('preserve_files')
  ->defaultValue(1);

$this->addFieldMapping('file_replace')
  ->defaultValue(MigrateFile::FILE_EXISTS_REUSE);
0

Maybe try:

$this->addFieldMapping('field_name', 'field_name');
$this->addFieldMapping('field_name:file_replace')->defaultValue(MigrateFile::FILE_EXISTS_REUSE);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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