ViewMode.php in Commerce Migrate 3.0.x
File
modules/commerce/src/Plugin/migrate/source/commerce1/ViewMode.php
View source
<?php
namespace Drupal\commerce_migrate_commerce\Plugin\migrate\source\commerce1;
use Drupal\field\Plugin\migrate\source\d7\ViewMode as CoreViewMode;
class ViewMode extends CoreViewMode {
protected function initializeIterator() {
$instances = parent::initializeIterator();
$rows = [];
foreach ($instances
->getArrayCopy() as $instance) {
$data = unserialize($instance['data']);
$instance['commerce1_entity_type'] = $instance['entity_type'];
foreach (array_keys($data['display']) as $view_mode) {
$key = $instance['entity_type'] . '.' . $view_mode;
$rows[$key] = array_merge($instance, [
'view_mode' => $view_mode,
]);
if ($instance['entity_type'] === 'node') {
$new_row = $instance;
$key = 'product_display.' . $view_mode;
$new_row['entity_type'] = 'product_display';
$new_row['commerce1_entity_type'] = 'product_display';
$rows[$key] = array_merge($new_row, [
'view_mode' => $view_mode,
]);
}
}
}
return new \ArrayIterator($rows);
}
}