CommercePrice.php in Commerce Migrate 3.1.x
File
modules/commerce/src/Plugin/migrate/field/commerce1/CommercePrice.php
View source
<?php
namespace Drupal\commerce_migrate_commerce\Plugin\migrate\field\commerce1;
use Drupal\migrate\Row;
use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase;
use Drupal\migrate\Plugin\MigrationInterface;
class CommercePrice extends FieldPluginBase {
public $fieldNameMap = [
'commerce_order_total' => 'total_price',
'commerce_total' => 'total_price',
'commerce_unit_price' => 'unit_price',
];
public function getFieldType(Row $row) {
return 'commerce_price';
}
public function getFieldFormatterMap() {
return [
'commerce_price_formatted_amount' => 'commerce_price_default',
'commerce_price_prefix_suffix' => 'commerce_price_default',
];
}
public function getFieldWidgetMap() {
return [
'commerce_price_full' => 'commerce_price_default',
'commerce_price_simple' => 'commerce_price_default',
];
}
public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $data) {
$destination_field_name = isset($this->fieldNameMap[$field_name]) ? $this->fieldNameMap[$field_name] : $field_name;
$process = [
'plugin' => 'commerce1_migrate_commerce_price',
'source' => $field_name,
];
$migration
->setProcessOfProperty($destination_field_name, $process);
}
public function processFieldValues(MigrationInterface $migration, $field_name, $data) {
$this
->defineValueProcessPipeline($migration, $field_name, $data);
}
}