You are here

public function CommerceSmartImporerService::exportPhysicalMeasurement in Commerce Smart Importer 8

Exports physical mesurement.

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

File

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

Class

CommerceSmartImporerService
This is main Commerce Smart Importer Service.

Namespace

Drupal\commerce_smart_importer\Plugin

Code

public function exportPhysicalMeasurement($entity, $field_definition) {
  if (!empty($entity
    ->get($field_definition['machine_names'])
    ->getValue())) {
    $value = $entity
      ->get($field_definition['machine_names'])
      ->getValue();
    return current($value)['number'] . ' ' . current($value)['unit'];
  }
  else {
    return '';
  }
}