You are here

public function CommerceSmartImporerService::duplicateValuesPass in Commerce Smart Importer 8

Helper function for createNewProduct.

Checks if field log contains duplicate values, returns corrected.

2 calls to CommerceSmartImporerService::duplicateValuesPass()
CommerceSmartImporerService::createNewProduct in src/Plugin/CommerceSmartImporerService.php
Creates product.
CommerceSmartImporerService::updateProduct in src/Plugin/CommerceSmartImporerService.php
Updates entity with given values.

File

src/Plugin/CommerceSmartImporerService.php, line 1390
Main Commerce Smart Importer Service.

Class

CommerceSmartImporerService
This is main Commerce Smart Importer Service.

Namespace

Drupal\commerce_smart_importer\Plugin

Code

public function duplicateValuesPass(&$field_log) {
  $new_values = [];
  $field_log['duplicates'] = TRUE;
  foreach ($field_log['values'] as $value) {
    if (!in_array($value, $new_values)) {
      $new_values[] = $value;
    }
    else {
      $field_log['duplicates'] = FALSE;
      $field_log['has_log'] = TRUE;
    }
  }
  $field_log['values'] = $new_values;
}