You are here

public function CommerceSmartImporerService::changeFilePathInFieldDefinition in Commerce Smart Importer 8

Changes file location in field definition.

File

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

Class

CommerceSmartImporerService
This is main Commerce Smart Importer Service.

Namespace

Drupal\commerce_smart_importer\Plugin

Code

public function changeFilePathInFieldDefinition(&$field_definitions, $path) {
  foreach ($field_definitions['product'] as $key => $field_definition) {
    if (!array_key_exists('field_settings', $field_definition)) {
      continue;
    }
    if (array_key_exists('file_directory', $field_definition['field_settings'])) {
      $field_definitions['product'][$key]['field_settings']['file_directory'] = $path;
    }
  }
  foreach ($field_definitions['variation'] as $key => $field_definition) {
    if (!array_key_exists('field_settings', $field_definition)) {
      continue;
    }
    if (array_key_exists('file_directory', $field_definition['field_settings'])) {
      $field_definitions['variation'][$key]['field_settings']['file_directory'] = $path;
    }
  }
}