Closed (fixed)
Project:
Migrate
Version:
7.x-2.3
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
30 Mar 2012 at 15:41 UTC
Updated:
14 Mar 2013 at 23:08 UTC
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 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