You are here

private function CSVUpdateForm::getIdentifiersIndex in Commerce Smart Importer 8

Returnst which indexes are identifiers.

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

File

src/Form/CSVUpdateForm.php, line 464

Class

CSVUpdateForm
Class CSVUpdateForm.

Namespace

Drupal\commerce_smart_importer\Form

Code

private function getIdentifiersIndex($fields) {
  $identifiers = $this->smartImporterService
    ->getIdentifierFields();
  $identifier_index = [
    'product' => [],
    'variation' => [],
  ];
  foreach ($fields['variation'] as $key => $field) {
    if (in_array($field['machine_names'], $identifiers['variation'])) {
      $identifier_index['variation'][] = $key;
    }
  }
  if (count($identifier_index['variation']) > 0) {
    $identifier_index['product'][] = 'variation';
  }
  foreach ($fields['product'] as $key => $field) {
    if (in_array($field['machine_names'], $identifiers['product'])) {
      $identifier_index['product'][] = $key;
    }
  }
  return $identifier_index;
}