ViewMode.php in Commerce Migrate 3.1.x
File
modules/ubercart/src/Plugin/migrate/source/uc6/ViewMode.php
View source
<?php
namespace Drupal\commerce_migrate_ubercart\Plugin\migrate\source\uc6;
use Drupal\node\Plugin\migrate\source\d6\ViewMode as NodeViewMode;
class ViewMode extends NodeViewMode {
protected function initializeIterator() {
$rows = [];
$result = $this
->prepareQuery()
->execute();
while ($field_row = $result
->fetchAssoc()) {
$field_row['display_settings'] = unserialize($field_row['display_settings']);
foreach ($this
->getViewModes() as $view_mode) {
if (isset($field_row['display_settings'][$view_mode]) && $field_row['display_settings'][$view_mode]['format'] != 'hidden' && empty($field_row['display_settings'][$view_mode]['exclude'])) {
if (!isset($rows[$view_mode])) {
$rows[$view_mode]['entity_type'] = 'node';
$rows[$view_mode]['view_mode'] = $view_mode;
$rows[$view_mode]['type_name'] = $field_row['type_name'];
}
}
}
}
return new \ArrayIterator($rows);
}
public function query() {
$query = parent::query();
$query
->addField('cnfi', 'type_name');
return $query;
}
public function fields() {
return [
'display_settings' => $this
->t('Serialize data with display settings.'),
'type_name' => $this
->t('The field bundle'),
];
}
}