You are here

public function CommerceSmartImporerService::exportDefaultField in Commerce Smart Importer 8

Helper function for exportField.

Most of fields type export.

1 call to CommerceSmartImporerService::exportDefaultField()
CommerceSmartImporerService::exportField in src/Plugin/CommerceSmartImporerService.php
Force different types of fields to string.

File

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

Class

CommerceSmartImporerService
This is main Commerce Smart Importer Service.

Namespace

Drupal\commerce_smart_importer\Plugin

Code

public function exportDefaultField($entity, $field_definition) {
  $values = [];
  if (!$entity
    ->hasField($field_definition['machine_names'])) {
    return '';
  }
  foreach ($entity
    ->get($field_definition['machine_names'])
    ->getValue() as $item) {
    $values[] = current($item);
  }
  $values = implode('|', $values);
  return $values;
}