I have to migrate from a WordPress web site to a Drupal 7 web site the place customers may add their very own photographs (like a number of person photos). I’ve a CSV file with Drupal Developer Consumer’s ID and a serialized array containing Drupal Developer filenames of uploaded photos (no, actually).
Customers have a multi-value picture area ‘field_user_pictures’.
After deserializing Drupal Developer array, drupal complains with Drupal Developer error “ltrim() expects parameter 1 to be string, array given”. (Presumably as a result of MigrateDestinationFile does not deal with arrays very properly.) Then I attempted with simply utilizing Drupal Developer first picture of Drupal Developer array, and that truly works. What does not work, nevertheless, is to get drupal to hyperlink this sole picture to Drupal Developer ‘field_user_pictures’ person area.
I’ve been making an attempt to get to one thing like this:
class PictureMigration extends Migration { public perform __construct ($arguments) { mum or dad::__construct($arguments); $supply = 'user_pictures.csv'; $columns = array( 1 => array('source_userid', ''), 3 => array('source_serialized', ''), ); $source_key = array('source_userid' => array('sort' => 'int', 'not null' => TRUE),); $this->supply = new MigrateSourceCSV($supply, $columns); $this->vacation spot = new MigrateDestinationFile('picture', 'MigrateFileUri'); $this->map = new MigrateSQLMap($this->machineName, $source_key, MigrateDestinationFile::getKeySchema()); $this->addFieldMapping('source_dir')->defaultValue($this->remote_dir); $this->addFieldMapping('destination_dir')->defaultValue('public://'); $this->addFieldMapping('worth', 'source_serialized'); } public perform prepareRow($row) { // snipped $row->source_serialized = $this->deserializePhotos($row->source_serialized); // returns array of filenames } } public class UserMigration extends Migration { public class __construct ($arguments) { // snipped... $this->addFieldMapping('field_user_pictures')->sourceMigration('PictureMigration'); } }
Drupal Development first downside is that MigrateDestinationFile does not appear to love multi-value values; Drupal Developer second downside is that even once I solely use Drupal Developer first filename of Drupal Developer array, it nonetheless does not get linked to Drupal Developer ‘field_user_pictures’ area…
See additionally: Migration: Mix Profile2 and file migration — virtually precisely Drupal Developer similar problem, however with no legitimate reply as properly.