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 trying to migrate multi-value file-fields.
I checked out the wine.inc but the sample provided doesn't work for me.
I tried to use JSON-encoded arrays that didn't work either and i read somewhere that method is now obsolete.
How to do this?
Here's what i have:
$this->addFieldMapping('field_case_file_upload', 'file_upload_url');
$this->addFieldMapping('field_case_file_upload:description', 'file_upload_title');
$this->addFieldMapping('field_case_file_upload:destination_dir')
->defaultValue('public://pdfs/sun_files');
public function prepareRow($current_row) {
$result = db_select('tbl_myfiles', 'f')
->fields('f', array('file_upload_url', 'file_upload_filepath', 'file_upload_title'))
->condition('content_id',$current_row->content_id)
->condition('f.file_upload_url', '%pdf%', 'LIKE')
->execute();
foreach ($result as $row) {
$current_row->file_upload_url[] = $row->file_upload_url;
$current_row->file_upload_filepath[] = $row->file_upload_filepath;
$current_row->file_upload_title[] = $row->file_upload_title;
return TRUE;
}
}
I am sure im not doing something right. Can someone cool please point me in the right direction? :)
Comments
Comment #0.0
Sunflower CreditAttribution: Sunflower commentedchange
Comment #0.1
Sunflower CreditAttribution: Sunflower commentedupdated code
Comment #1
Sunflower CreditAttribution: Sunflower commentedFigured this out. I just needed to add the fields to $source_fields as done in the sample wine.inc.
Comment #1.0
Sunflower CreditAttribution: Sunflower commentedblah