ProductType.php in Commerce Migrate 3.1.x
File
modules/commerce/src/Plugin/migrate/source/commerce1/ProductType.php
View source
<?php
namespace Drupal\commerce_migrate_commerce\Plugin\migrate\source\commerce1;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
use Drupal\migrate\Row;
class ProductType extends DrupalSqlBase {
public function fields() {
return [
'type' => $this
->t('Type'),
'name' => $this
->t('Name'),
'description' => $this
->t('Description'),
'help' => $this
->t('Help'),
'revision' => $this
->t('Revision'),
'line_item_type' => $this
->t('Line item type'),
];
}
public function getIds() {
$ids['type']['type'] = 'string';
$ids['type']['alias'] = 'pt';
return $ids;
}
public function prepareRow(Row $row) {
$type = $row
->getSourceProperty('type');
$data = $this
->select('field_config_instance', 'fci')
->fields('fci', [
'data',
])
->condition('fci.bundle', $type)
->condition('data', '%line_item_type%', 'LIKE')
->execute()
->fetchCol();
$data = empty($data) ?: unserialize($data[0]);
$line_item_type = isset($data['display']['default']['settings']['line_item_type']) ? $data['display']['default']['settings']['line_item_type'] : '';
$row
->setSourceProperty('line_item_type', $line_item_type);
return parent::prepareRow($row);
}
public function query() {
$query = $this
->select('commerce_product_type', 'pt')
->fields('pt');
return $query;
}
}
Classes
Name |
Description |
ProductType |
Gets Commerce 1 commerce_product_type data from database. |