public function CommerceSmartImporerService::useDefaultValuePass in Commerce Smart Importer 8
Helper function for createNewProduct.
If needed this will use default value.
2 calls to CommerceSmartImporerService::useDefaultValuePass()
- 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 1429 - Main Commerce Smart Importer Service.
Class
- CommerceSmartImporerService
- This is main Commerce Smart Importer Service.
Namespace
Drupal\commerce_smart_importer\PluginCode
public function useDefaultValuePass(&$field_log, $field_definition) {
$default_index = $field_definition['field_types'] == 'image' ? 'default_image' : 'default_value';
if (count($field_log['values']) == 0 && $field_definition['field_settings'][$default_index] !== FALSE) {
if ($field_definition['field_settings'][$default_index] == 'generateSKU') {
$field_log['values'] = [
$this
->generateSku(),
];
$field_log['default_value'] = FALSE;
$field_log['has_log'] = TRUE;
}
else {
$field_log['values'] = $field_definition['field_settings'][$default_index];
$field_log['default_value'] = FALSE;
$field_log['has_log'] = TRUE;
}
}
else {
$field_log['default_value'] = TRUE;
}
}