You are here

public function CommerceSmartImporerService::exportField in Commerce Smart Importer 8

Force different types of fields to string.

1 call to CommerceSmartImporerService::exportField()
CommerceSmartImporerService::exportMultipleFields in src/Plugin/CommerceSmartImporerService.php
Exports groups of entity based on field_deifnitions.

File

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

Class

CommerceSmartImporerService
This is main Commerce Smart Importer Service.

Namespace

Drupal\commerce_smart_importer\Plugin

Code

public function exportField($entity, $field_definition) {
  $value = '';
  switch ($field_definition['field_types']) {
    case 'text':
    case 'text_long':
    case 'string_long':
    case 'float':
    case 'decimal':
    case 'timestamp':
    case 'email':
    case 'link':
    case 'boolean':
    case 'string':
    case 'text_with_summary':
    case 'weight':
    case 'list_string':
    case 'list_float':
    case 'list_integer':
    case 'integer':
      $value = $this
        ->exportDefaultField($entity, $field_definition);
      break;
    case 'commerce_price':
      $value = $this
        ->exportPrice($entity, $field_definition);
      break;
    case 'currency':
      $value = $this
        ->exportCurrency($entity);
      break;
    case 'entity_reference':
      $value = $this
        ->exportEntity($entity, $field_definition);
      break;
    case 'image':
    case 'file':
      $value = $this
        ->exportImage($entity, $field_definition);
      break;
    case 'physical_measurement':
      $value = $this
        ->exportPhysicalMeasurement($entity, $field_definition);
      break;
    case 'redirection':
      $value = '';
      break;
    default:
      $value = $this
        ->exportDefaultField($entity, $field_definition);
      break;
  }
  return $value;
}