diff --git a/modules/entity_share_client/src/Service/ImportService.php b/modules/entity_share_client/src/Service/ImportService.php index 5fd17bf..480c177 100644 --- a/modules/entity_share_client/src/Service/ImportService.php +++ b/modules/entity_share_client/src/Service/ImportService.php @@ -297,7 +297,6 @@ class ImportService implements ImportServiceInterface { foreach ($this->importProcessors[ImportProcessorInterface::STAGE_PROCESS_ENTITY] as $import_processor) { $import_processor->processEntity($this->runtimeImportContext, $processed_entity, $entity_data); } - $processed_entity->save(); foreach ($this->importProcessors[ImportProcessorInterface::STAGE_POST_ENTITY_SAVE] as $import_processor) { @@ -456,6 +455,14 @@ class ImportService implements ImportServiceInterface { // New entity. if (empty($existing_entities)) { + // TODO: Support metatags. + foreach (['field_metatags', 'field_meta_tags'] as $field_name) { + if (!$remote_entity->hasField($field_name)) { + continue; + } + $metatags_remote_values = $remote_entity->get($field_name)->getValue(); + $remote_entity->set($field_name, serialize($metatags_remote_values[0] ?? [])); + } // Save the entity to have an ID for entity reference management. // If A -> B -> A, and A is not saved, when recursively importing A, B // will not be able to reference A. @@ -476,10 +483,17 @@ class ImportService implements ImportServiceInterface { // For example, JSON:API extras field enhancers plugins. foreach (array_keys($entity_data['attributes']) as $field_public_name) { $field_internal_name = array_search($field_public_name, $field_mappings[$entity_type_id][$entity_bundle]); - if ($field_internal_name && $existing_translation->hasField($field_internal_name)) { + if ($field_internal_name && $existing_translation->hasField($field_internal_name) && $field_internal_name != 'metatag') { + if (in_array($field_internal_name, ['field_metatags', 'field_meta_tags'])) { + $metatags_remote_values = $remote_entity->get($field_internal_name)->getValue(); + $value = serialize($metatags_remote_values[0] ?? []); + } + else { + $value = $remote_entity->get($field_internal_name)->getValue(); + } $existing_translation->set( $field_internal_name, - $remote_entity->get($field_internal_name)->getValue() + $value ); } else {