Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function prepareRow(Row $row)
 {
     $uid = $row->getSourceProperty('uid');
     // field_real_name
     $result = $this->getDatabase()->query('
   SELECT
     fld.field_real_name_value
   FROM
     {dcf_field_data_field_real_name} fld
   WHERE
     fld.entity_id = :uid
 ', array(':uid' => $uid));
     foreach ($result as $record) {
         $row->setSourceProperty('field_real_name', $record->field_real_name_value);
     }
     // field_availability
     $result = $this->getDatabase()->query('
   SELECT
     fld.field_availability_value
   FROM
     {dcf_field_data_field_availability} fld
   WHERE
     fld.entity_id = :uid
 ', array(':uid' => $uid));
     foreach ($result as $record) {
         $row->setSourceProperty('field_availability', $record->field_availability_value);
     }
     return parent::prepareRow($row);
 }
 /**
  * {@inheritdoc}
  */
 public function prepareRow(Row $row)
 {
     /**
      * prepareRow() is the most common place to perform custom run-time
      * processing that isn't handled by an existing process plugin. It is called
      * when the raw data has been pulled from the source, and provides the
      * opportunity to modify or add to that data, creating the canonical set of
      * source data that will be fed into the processing pipeline.
      *
      * In our particular case, the list of a user's favorite ssds is a pipe-
      * separated list of ssd IDs. The processing pipeline deals with arrays
      * representing multi-value fields naturally, so we want to explode that
      * string to an array of individual ssd IDs.
      */
     if ($value = $row->getSourceProperty('ssds')) {
         $row->setSourceProperty('ssds', explode('|', $value));
     }
     /**
      * Always call your parent! Essential processing is performed in the base
      * class. Be mindful that prepareRow() returns a boolean status - if FALSE
      * that indicates that the item being processed should be skipped. Unless
      * we're deciding to skip an item ourselves, let the parent class decide.
      */
     return parent::prepareRow($row);
 }
Esempio n. 3
0
 /**
  * {@inheritdoc}
  */
 public function prepareRow(Row $row)
 {
     $nid = $row->getSourceProperty('nid');
     // taxonomy term IDs
     // (here we use MySQL's GROUP_CONCAT() function to merge all values into one row.)
     $result = $this->getDatabase()->query('
   SELECT
     GROUP_CONCAT(fld.field_links_tags_tid) as tids
   FROM
     {dcf_field_data_field_links_tags} fld
   WHERE
     fld.entity_id = :nid
 ', array(':nid' => $nid));
     foreach ($result as $record) {
         if (!is_null($record->tids)) {
             $row->setSourceProperty('tags', explode(',', $record->tids));
         }
     }
     // field_url
     $result = $this->getDatabase()->query('
   SELECT
     fld.field_url_url as url,
     fld.field_url_title as title
   FROM
     {dcf_field_data_field_url} fld
   WHERE
     fld.entity_id = :nid
 ', array(':nid' => $nid));
     foreach ($result as $record) {
         $row->setSourceProperty('field_url_url', $record->url);
         $row->setSourceProperty('field_url_title', $record->title);
     }
     return parent::prepareRow($row);
 }
Esempio n. 4
0
 /**
  * {@inheritdoc}
  */
 public function prepareRow(Row $row)
 {
     // Find parents for this row.
     $parents = $this->select('dcf_taxonomy_term_hierarchy', 'th')->fields('th', array('parent', 'tid'))->condition('tid', $row->getSourceProperty('tid'))->execute()->fetchCol();
     $row->setSourceProperty('parent', $parents);
     return parent::prepareRow($row);
 }
Esempio n. 5
0
 /**
  * {@inheritdoc}
  */
 public function prepareRow(Row $row)
 {
     $vocab = $row->getSourceProperty('taxonomy');
     $label = $vocab == 'category' ? 'Category' : 'Post Tags';
     $row->setSourceProperty('label', $label);
     return parent::prepareRow($row);
 }
 /**
  * {@inheritdoc}
  */
 public function prepareRow(Row $row)
 {
     if (parent::prepareRow($row) === FALSE) {
         return FALSE;
     }
     $speakerIds = $row->getSourceProperty('speaker_ids');
     $row->setSourceProperty('speaker_ids', explode(',', $speakerIds));
 }
 /**
  * {@inheritdoc}
  */
 public function prepareRow(Row $row)
 {
     if (parent::prepareRow($row) === FALSE) {
         return FALSE;
     }
     $date = $row->getSourceProperty('date');
     $row->setSourceProperty('date', date('Y-m-d', $date));
 }
 /**
  * {@inheritdoc}
  */
 public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state)
 {
     parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state);
     $this->table_name = $this->configuration['table_name'];
     $this->fields_list = $this->configuration['fields_list'];
     if (!empty($this->configuration['ids'])) {
         $this->ids = $this->configuration['ids'];
     }
 }
Esempio n. 9
0
 /**
  * {@inheritdoc}
  */
 public function prepareRow(Row $row)
 {
     $row->setSourceProperty('post_date', strtotime($row->getSourceProperty('post_date')));
     $row->setSourceProperty('post_modified', strtotime($row->getSourceProperty('post_modified')));
     // This gathers up WordPress tags and categories and applies it to the hard
     // code field name field_tags in migrate.migration.wp_posts.yml. Use
     // hook_migration_load() to update the field name or simply copy the
     // migration.
     $this->applyCustomTagsFieldMapping($row);
     return parent::prepareRow($row);
 }
Esempio n. 10
0
 /**
  * {@inheritdoc}
  */
 public function prepareRow(Row $row)
 {
     // Find parents for this row.
     $query = $this->select('wp_term_taxonomy', 'wptt')->fields('wptt', array('parent', 'term_id', 'taxonomy', 'description'))->condition('term_id', $row->getSourceProperty('term_id'))->execute()->fetchAssoc();
     if (!empty($query)) {
         $row->setSourceProperty('parent', $query['parent']);
         $row->setSourceProperty('description', $query['description']);
         $row->setSourceProperty('vid', $query['taxonomy']);
     }
     return parent::prepareRow($row);
 }
 /**
  * {@inheritdoc}
  */
 public function prepareRow(Row $row)
 {
     // The Migrate API automatically serializes arrays for storage in longblob
     // fields so we unserialize them here.
     $attributes = unserialize($row->getSourceProperty('data'));
     // In Ubercart, the module key is set to 'uc_order' so it's removed for
     // D8 Commerce.
     unset($attributes['module']);
     $row->setSourceProperty('attributes', $attributes);
     return parent::prepareRow($row);
 }
 /**
  * {@inheritdoc}
  */
 public function prepareRow(Row $row)
 {
     parent::prepareRow($row);
     // Get filename property value.
     $filename = $row->getSourceProperty('filename');
     // Prepare base path.
     $base_path = trim($this->configuration['source_base_path'], '/');
     // Set "full_path" property to point to the full path of the image.
     $base_module_path = drupal_get_path('module', 'migrate_source_example');
     $row->setSourceProperty('full_path', $base_module_path . '/' . $base_path . '/' . $filename);
 }
 /**
  * {@inheritdoc}
  */
 public function prepareRow(Row $row)
 {
     // This is just an example of how to import images into a multiple image
     // field.
     //$image_ids = $this->select('content_field_image_cache', 'cfic')
     //  ->fields('cfic', ['field_image_cache_fid'])
     //  ->condition('nid', $row->getSourceProperty('nid'))
     //  ->condition('vid', $row->getSourceProperty('vid'))
     //  ->execute()
     //  ->fetchCol();
     //$row->setSourceProperty('images', $image_ids);
     $row->setSourceProperty('name', str_replace(' ', '_', strtolower($row->getSourceProperty('name'))));
     return parent::prepareRow($row);
 }
Esempio n. 14
0
 /**
  * {@inheritdoc}
  */
 public function prepareRow(Row $row)
 {
     /**
      * As explained above, we need to pull the style relationships into our
      * source row here, as an array of 'style' values (the unique ID for
      * the ssd_term migration).
      */
     $terms = $this->select('migrate_example_ssd_topic_node', 'bt')->fields('bt', ['style'])->condition('bbid', $row->getSourceProperty('bbid'))->execute()->fetchCol();
     $row->setSourceProperty('terms', $terms);
     // As we did for favorite ssd in the user migration, we need to explode
     // the multi-value country names.
     if ($value = $row->getSourceProperty('countries')) {
         $row->setSourceProperty('countries', explode('|', $value));
     }
     return parent::prepareRow($row);
 }
Esempio n. 15
0
 /**
  * {@inheritdoc}
  */
 public function prepareRow(Row $row)
 {
     # Sets billing address to address on most recent order. This may not be
     # appropriate for most use cases since it would require to maintain an
     # old Ubercart version of the site to lookup addresses for old orders.
     $default = Database::getConnection('default');
     $profile = $default->select('profile', 'p')->fields('p', ['profile_id'])->condition('uid', $row->getSourceProperty('uid'))->execute()->fetchCol();
     $row->setSourceProperty('billing_id', $profile[0]);
     // The Migrate API automatically serializes arrays for storage in longblob
     // fields so we unserialize them here.
     $attributes = unserialize($row->getSourceProperty('data'));
     // Ubercart 6 stores credit card information in a hash. Since this probably
     // isn't necessary so I removed it here.
     unset($attributes['cc_data']);
     $row->setSourceProperty('attributes', $attributes);
     return parent::prepareRow($row);
 }
 public function prepareRow(Row $row)
 {
     // do my row mods here..
     // Bail if this is a non-published recipe
     //$status = $row->getSourceProperty("status");
     //if ($status != 'Published') {
     //  return FALSE;
     //}
     //$filename = $row->getSourceProperty("filename") ;
     //$str = sprintf("Processing: %s", $filename);
     //drush_print_r($str);
     $url = $row->getSourceProperty("url");
     $str = sprintf("Processing: %s", $url);
     drush_print_r($str);
     $filename_with_path = basename($url);
     $filename_with_path = 'public://product-images/' . $filename_with_path;
     drush_print_r($filename_with_path);
     $row->setSourceProperty('filename_with_path', $filename_with_path);
     return parent::prepareRow($row);
 }
Esempio n. 17
0
 /**
  * {@inheritdoc}
  */
 public function prepareRow(Row $row)
 {
     $nid = $row->getSourceProperty('nid');
     // body (compound field with value, summary, and format)
     $result = $this->getDatabase()->query('
   SELECT
     fld.body_value,
     fld.body_summary,
     fld.body_format
   FROM
     {dcf_field_data_body} fld
   WHERE
     fld.entity_id = :nid
 ', array(':nid' => $nid));
     foreach ($result as $record) {
         $row->setSourceProperty('body_value', $record->body_value);
         $row->setSourceProperty('body_summary', $record->body_summary);
         $row->setSourceProperty('body_format', $record->body_format);
     }
     // taxonomy term IDs
     // (here we use MySQL's GROUP_CONCAT() function to merge all values into one row.)
     $result = $this->getDatabase()->query('
   SELECT
     GROUP_CONCAT(fld.field_tags_tid) as tids
   FROM
     {dcf_field_data_field_tags} fld
   WHERE
     fld.entity_id = :nid
 ', array(':nid' => $nid));
     foreach ($result as $record) {
         if (!is_null($record->tids)) {
             $row->setSourceProperty('tags', explode(',', $record->tids));
         }
     }
     return parent::prepareRow($row);
 }
 /**
  * {@inheritdoc}
  */
 public function prepareRow(Row $row)
 {
     // Creates a new source row field named 'node_id' with the 'nid' value.
     $row->setSourceProperty('node_id', $row->getSourceProperty('nid'));
     return parent::prepareRow($row);
 }
 /**
  * {@inheritdoc}
  */
 public function prepareRow(Row $row)
 {
     /**
      * Let's go get the subTeam taxonomy tid for each product
      */
     $start = $row->getSourceProperty('salestart');
     if (!is_null($start)) {
         //      drupal_set_message('start:' . $start) ;
         $timestamp = strtotime($start);
         $start = date("Y-m-d\\TH:i:s", $timestamp);
         //      drupal_set_message('reformatted start: ' . $start);
         $row->setSourceProperty('salestart', $start);
     }
     $end = $row->getSourceProperty('saleend');
     if (!is_null($end)) {
         //      drupal_set_message('end:' . $end);
         $timestamp = strtotime($start);
         $end = date("Y-m-d\\TH:i:s", $timestamp);
         //      drupal_set_message('reformatted end: ' . $end);
         $row->setSourceProperty('saleend', $end);
     }
     // Fill in the field_product_ref entity ref to the product node.
     $id = $row->getSourceProperty('identifier');
     $product_ref_id = $this->lookupProductNid($id);
     $row->setSourceProperty('product_ref_id', $product_ref_id);
     $tlc = $row->getSourceProperty('tlc');
     $store_ref_id = $this->lookupStoreNid($tlc);
     $row->setSourceProperty('store_ref_id', $store_ref_id);
     $ssid = $row->getSourceProperty('ssid');
     drupal_set_message('Processing: ' . $ssid);
     /**
      * As explained above, we need to pull the style relationships into our
      * source row here, as an array of 'style' values (the unique ID for
      * the beer_term migration).
      */
     //    $terms = $this->select('migrate_example_beer_topic_node', 'bt')
     //      ->fields('bt', ['style'])
     //      ->condition('bid', $row->getSourceProperty('bid'))
     //      ->execute()
     //      ->fetchCol();
     //    $row->setSourceProperty('terms', $terms);
     // As we did for favorite beers in the user migration, we need to explode
     // the multi-value country names.
     //    if ($value = $row->getSourceProperty('countries')) {
     //      $row->setSourceProperty('countries', explode('|', $value));
     //    }
     return parent::prepareRow($row);
     //  }
 }
Esempio n. 20
0
 /**
  * {@inheritdoc}
  */
 public function prepareRow(Row $row)
 {
     $genres = $this->select('movies_genres', 'g')->fields('g', ['id'])->condition('movie_id', $row->getSourceProperty('id'))->execute()->fetchCol();
     $row->setSourceProperty('genres', $genres);
     return parent::prepareRow($row);
 }
 /**
  * {@inheritdoc}
  */
 public function prepareRow(Row $row)
 {
     // In the Ubercart 6 order table, countries are stored by country ID
     // integer value but in Commerce 8, they are stored as ISO codes. This
     // query uses the Ubercart 6 'uc_countries' table as a lookup.
     $country_code = $this->select('uc_countries', 'uc')->fields('uc', ['country_iso_code_2'])->condition('country_id', $row->getSourceProperty('billing_country'))->execute()->fetchCol();
     $row->setSourceProperty('billing_country', $country_code[0]);
     // In the Ubercart 6 order table, zones (state, provinces, etc.) are
     // stored as foreign key values so looking up the zone abbreviations
     // in the 'uc_zones' table is necessary.
     $administrative_area = $this->select('uc_zones', 'uz')->fields('uz', ['zone_code'])->condition('zone_id', $row->getSourceProperty('billing_zone'))->execute()->fetchCol();
     if (!empty($administrative_area[0])) {
         $row->setSourceProperty('billing_zone', $country_code[0] . '-' . $administrative_area[0]);
     } else {
         $row->setSourceProperty('billing_zone', '');
     }
     return parent::prepareRow($row);
 }
Esempio n. 22
0
 /**
  * {@inheritdoc}
  */
 public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityManagerInterface $entity_manager)
 {
     parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state);
     $this->entityManager = $entity_manager;
 }
Esempio n. 23
0
 /**
  * {@inheritdoc}
  */
 public function prepareRow(Row $row)
 {
     $row->setSourceProperty('comment_date', strtotime($row->getSourceProperty('comment_date')));
     $row->setSourceProperty('comment_date_gmt', strtotime($row->getSourceProperty('comment_date_gmt')));
     return parent::prepareRow($row);
 }
Esempio n. 24
0
 /**
  * {@inheritdoc}
  */
 public function mapJoinable()
 {
     return parent::mapJoinable();
 }
Esempio n. 25
0
 /**
  * {@inheritdoc}
  */
 public function prepareRow(Row $row)
 {
     $nid = $row->getSourceProperty('nid');
     // field_short_bio
     $result = $this->getDatabase()->query('
   SELECT
     fld.field_short_bio_value as bio
   FROM
     {dcf_field_data_field_short_bio} fld
   WHERE
     fld.entity_id = :nid
 ', array(':nid' => $nid));
     foreach ($result as $record) {
         $row->setSourceProperty('field_short_bio', $record->bio);
     }
     // field_image
     $result = $this->getDatabase()->query('
   SELECT
     fld.field_image_fid,
     fld.field_image_alt,
     fld.field_image_title,
     fld.field_image_width,
     fld.field_image_height
   FROM
     {dcf_field_data_field_image} fld
   WHERE
     fld.entity_id = :nid
 ', array(':nid' => $nid));
     // Create an associative array for each row in the result. The keys
     // here match the last part of the column name in the field table.
     $images = [];
     foreach ($result as $record) {
         $images[] = ['target_id' => $record->field_image_fid, 'alt' => $record->field_image_alt, 'title' => $record->field_image_title, 'width' => $record->field_image_width, 'height' => $record->field_image_height];
     }
     $row->setSourceProperty('field_image', $images);
     // field_linkedin_url
     $result = $this->getDatabase()->query('
   SELECT
     fld.field_linkedin_url_url as linkedin
   FROM
     {dcf_field_data_field_linkedin_url} fld
   WHERE
     fld.entity_id = :nid
 ', array(':nid' => $nid));
     foreach ($result as $record) {
         $row->setSourceProperty('field_linkedin_url_url', $record->linkedin);
     }
     return parent::prepareRow($row);
 }