You are here

private function CSVExportForm::leaveOnlyCheckedFields in Commerce Smart Importer 8

Unsets fields that are not checked.

1 call to CSVExportForm::leaveOnlyCheckedFields()
CSVExportForm::submitForm in src/Form/CSVExportForm.php
Submits form.

File

src/Form/CSVExportForm.php, line 417

Class

CSVExportForm
Form for exporting products in CSV format.

Namespace

Drupal\commerce_smart_importer\Form

Code

private function leaveOnlyCheckedFields(&$fields, $field_list) {
  foreach ($fields['product'] as $key => $field) {
    if (!in_array($field['machine_names'], $field_list)) {
      unset($fields['product'][$key]);
    }
  }
  foreach ($fields['variation'] as $key => $field) {
    if (!in_array($field['machine_names'], $field_list)) {
      unset($fields['variation'][$key]);
    }
  }
}