Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Started discussing this on #1279778: Improve argument passing to fields
I'm trying to map both the location and the description to a multi-value file field.
This is working for me for multiple values:
public function prepareRow($current_row)
{
$attachments = db_select('legacy_news_attachments','a')
->fields('a', array('prid','location'))
->condition('prid',$current_row->prid)
->execute();
$attachments_locations = array();
foreach($attachments as $attachment)
{
$attachments_locations[] = $attachment->location;
}
$current_row->attachments_location = $attachments_locations;
return TRUE;
}
This is working for me for the description and the location (but I don't know how to do this for multiple value fields)
$arguments = MigrateFileFieldHandler::arguments(NULL, 'file_copy', FILE_EXISTS_RENAME, NULL, NULL, NULL, array('source_field' => 'attachments_description'));
$this->addFieldMapping('field_attachment', 'attachments_location')
->arguments($arguments);
Does anybody know how to do this?
Comments
Comment #1
mikeryanPer http://drupal.org/node/1005090#comment-4450746, you should be able to make attachments_location an array of JSON-encoded arrays, one per image being migrated. In migrate_example's wine.inc, see WineWineMigration::prepareRow() for an example.
Does this help?
Comment #2
puddyglumThat's awesome, it worked great!
Added this feature to the documentation page Advanced field mappings
Comment #3
puddyglumComment #5
Sunflower CreditAttribution: Sunflower commentedHi Mike,
Does json-encoded arrays still work? I tried the wine.inc no luck. Any ideas what i am doing wrong? http://drupal.org/node/1943324