Product.php in Commerce Migrate 3.0.x
File
modules/ubercart/src/Plugin/migrate/source/uc7/Product.php
View source
<?php
namespace Drupal\commerce_migrate_ubercart\Plugin\migrate\source\uc7;
use Drupal\migrate\Row;
use Drupal\node\Plugin\migrate\source\d7\Node;
class Product extends Node {
public function query() {
$query = parent::query();
$query
->innerJoin('uc_products', 'ucp', 'n.nid = ucp.nid AND n.vid = ucp.vid');
$query
->fields('ucp', [
'model',
'sell_price',
]);
if (isset($this->configuration['node_type'])) {
$query
->condition('n.type', $this->configuration['node_type']);
}
return $query;
}
public function fields() {
$fields = [
'model' => $this
->t('Product model'),
'sell_price' => $this
->t('Sell price of the product'),
'name' => $this
->t('Node type'),
'stores' => $this
->t('Stores'),
];
return parent::fields() + $fields;
}
public function prepareRow(Row $row) {
$row
->setSourceProperty('stores', 1);
return parent::prepareRow($row);
}
}