ProductVariationTrait.php in Commerce Migrate 8.2
File
modules/ubercart/src/Plugin/migrate/source/ProductVariationTrait.php
View source
<?php
namespace Drupal\commerce_migrate_ubercart\Plugin\migrate\source;
use Drupal\migrate\Row;
trait ProductVariationTrait {
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',
]);
return $query;
}
public function fields() {
$fields = [
'vid' => t('The primary identifier for this version.'),
'log' => $this
->t('Revision Log message'),
'uid' => $this
->t('Node UID.'),
'model' => $this
->t('SKU code'),
'sell_price' => $this
->t('Product price'),
];
return parent::fields() + $fields;
}
public function prepareRow(Row $row) {
$row
->setSourceProperty('currency', $this
->getUbercartCurrency());
return parent::prepareRow($row);
}
public function getUbercartCurrency() {
static $currency;
if (empty($currency)) {
$currency = $this
->variableGet('uc_currency_code', 'USD');
}
return $currency;
}
}