ViewMode.php in Commerce Migrate 3.1.x
File
modules/ubercart/src/Plugin/migrate/source/uc7/ViewMode.php
View source
<?php
namespace Drupal\commerce_migrate_ubercart\Plugin\migrate\source\uc7;
use Drupal\field\Plugin\migrate\source\d7\FieldInstance;
use Drupal\field\Plugin\migrate\source\d7\ViewMode as CoreViewMode;
class ViewMode extends CoreViewMode {
use ProductTypeTrait;
protected function initializeIterator() {
$instances = FieldInstance::initializeIterator();
$this->productTypes = $this
->getProductTypes();
$rows = [];
foreach ($instances
->getArrayCopy() as $instance) {
$data = unserialize($instance['data']);
foreach (array_keys($data['display']) as $view_mode) {
$key = $instance['entity_type'] . '.' . $view_mode;
if (in_array($instance['bundle'], $this->productTypes)) {
$key = 'commerce_product .' . $view_mode;
$instance['entity_type'] = 'commerce_product';
}
$rows[$key] = array_merge($instance, [
'view_mode' => $view_mode,
]);
}
}
return new \ArrayIterator($rows);
}
}