diff --git a/src/api/endpoints/class-tainacan-rest-importers-controller.php b/src/api/endpoints/class-tainacan-rest-importers-controller.php index ba10b92e1..7fa7ffb01 100644 --- a/src/api/endpoints/class-tainacan-rest-importers-controller.php +++ b/src/api/endpoints/class-tainacan-rest-importers-controller.php @@ -201,22 +201,6 @@ class REST_Importers_Controller extends REST_Controller { if ($att == 'collection') { if (is_array($value) && isset($value['id'])) { - - if(isset($value['mapping']) && is_array($value['mapping'])){ - foreach( $value['mapping'] as $metadatum_id => $header ){ - - if( !is_numeric($metadatum_id) ) { - $metadatum = $importer->create_new_metadata( $header, $value['id']); - - if( is_object($metadatum) ){ - unset($value['mapping'][$metadatum_id]); - $value['mapping'][$metadatum->get_id()] = $header; - } - - } - } - } - $importer->add_collection($value); continue; } else { diff --git a/src/importer/class-tainacan-csv.php b/src/importer/class-tainacan-csv.php index ec39835aa..aa6203fdf 100644 --- a/src/importer/class-tainacan-csv.php +++ b/src/importer/class-tainacan-csv.php @@ -715,6 +715,20 @@ class CSV extends Importer { if (isset($collection['id'])) { if( isset($collection['mapping']) && is_array($collection['mapping']) ){ + + foreach( $collection['mapping'] as $metadatum_id => $header ){ + + if( !is_numeric($metadatum_id) ) { + $metadatum = $this->create_new_metadata( $header, $collection['id']); + + if( is_object($metadatum) ){ + unset($collection['mapping'][$metadatum_id]); + $collection['mapping'][$metadatum->get_id()] = $header; + } + + } + } + $this->save_mapping( $collection['id'], $collection['mapping'] ); }