trait ProductVariationTrait in Commerce Migrate 3.0.x
Same name and namespace in other branches
- 8.2 modules/ubercart/src/Plugin/migrate/source/ProductVariationTrait.php \Drupal\commerce_migrate_ubercart\Plugin\migrate\source\ProductVariationTrait
- 3.1.x modules/ubercart/src/Plugin/migrate/source/ProductVariationTrait.php \Drupal\commerce_migrate_ubercart\Plugin\migrate\source\ProductVariationTrait
Ubercart product variation source.
Hierarchy
- trait \Drupal\commerce_migrate_ubercart\Plugin\migrate\source\ProductVariationTrait
2 files declare their use of ProductVariationTrait
- ProductVariation.php in modules/
ubercart/ src/ Plugin/ migrate/ source/ uc7/ ProductVariation.php - ProductVariation.php in modules/
ubercart/ src/ Plugin/ migrate/ source/ uc6/ ProductVariation.php
File
- modules/
ubercart/ src/ Plugin/ migrate/ source/ ProductVariationTrait.php, line 10
Namespace
Drupal\commerce_migrate_ubercart\Plugin\migrate\sourceView source
trait ProductVariationTrait {
/**
* {@inheritdoc}
*/
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;
}
/**
* {@inheritdoc}
*/
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;
}
/**
* {@inheritdoc}
*/
public function prepareRow(Row $row) {
// Set the currency for each variation based on Ubercart global setting.
$row
->setSourceProperty('currency', $this
->getUbercartCurrency());
return parent::prepareRow($row);
}
/**
* Gets the Ubercart global currency.
*
* @return string
* The currency.
*/
public function getUbercartCurrency() {
static $currency;
if (empty($currency)) {
$currency = $this
->variableGet('uc_currency_code', 'USD');
}
return $currency;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ProductVariationTrait:: |
public | function | ||
ProductVariationTrait:: |
public | function | Gets the Ubercart global currency. | |
ProductVariationTrait:: |
public | function | ||
ProductVariationTrait:: |
public | function |