public function Currency::prepareRow in Commerce Migrate 8.2
Same name in this branch
- 8.2 modules/ubercart/src/Plugin/migrate/source/Currency.php \Drupal\commerce_migrate_ubercart\Plugin\migrate\source\Currency::prepareRow()
- 8.2 modules/commerce/src/Plugin/migrate/source/commerce1/Currency.php \Drupal\commerce_migrate_commerce\Plugin\migrate\source\commerce1\Currency::prepareRow()
Same name and namespace in other branches
- 3.1.x modules/commerce/src/Plugin/migrate/source/commerce1/Currency.php \Drupal\commerce_migrate_commerce\Plugin\migrate\source\commerce1\Currency::prepareRow()
- 3.0.x modules/commerce/src/Plugin/migrate/source/commerce1/Currency.php \Drupal\commerce_migrate_commerce\Plugin\migrate\source\commerce1\Currency::prepareRow()
Adds additional data to the row.
Parameters
\Drupal\migrate\Row $row: The row object.
Return value
bool FALSE if this row needs to be skipped.
Overrides SourcePluginBase::prepareRow
File
- modules/
commerce/ src/ Plugin/ migrate/ source/ commerce1/ Currency.php, line 76
Class
- Currency
- Gets the Commerce 1 currency data.
Namespace
Drupal\commerce_migrate_commerce\Plugin\migrate\source\commerce1Code
public function prepareRow(Row $row) {
// Get the currency name and the country numeric code by using the
// destination's currency importer. These values are not available from
// the ubercart source.
// @todo find a better to get the currency name and the country numeric code
// without peeking into the destination.
// Use Commerce 1 default if commerce_default_currency was unset.
if (empty($row
->getSourceProperty('commerce_default_currency'))) {
$row
->setSourceProperty('commerce_default_currency', 'USD');
}
$currencyImporter = new CurrencyImporter($this->entityTypeManager, $this->languageManager);
$currency = $currencyImporter
->import($row
->getSourceProperty('commerce_default_currency'));
$name = $currency
->getName();
$numeric_code = $currency
->getNumericCode();
$row
->setSourceProperty('currency_name', $name);
$row
->setSourceProperty('numeric_code', $numeric_code);
return parent::prepareRow($row);
}