You are here

public function CSVUpdateForm::reformatLine in Commerce Smart Importer 8

Reformat price and currency.

1 call to CSVUpdateForm::reformatLine()
CSVUpdateForm::readCsvProductsToUpdate in src/Form/CSVUpdateForm.php
Reads and formats products for update.

File

src/Form/CSVUpdateForm.php, line 414

Class

CSVUpdateForm
Class CSVUpdateForm.

Namespace

Drupal\commerce_smart_importer\Form

Code

public function reformatLine(&$line, $fields) {
  foreach ($fields as $field) {
    if ($field['machine_names'] == 'currency') {
      $currency = $line[$field['index']];
      unset($line[$field['index']]);
      break;
    }
  }
  if (!isset($currency)) {
    return;
  }
  foreach ($fields as $field) {
    if ($field['field_types'] == 'commerce_price') {
      $line[$field['index']] .= ' ' . $currency;
    }
  }
}