fix: create order of metadata on importing csv only if there is no previous order

This commit is contained in:
vnmedeiros 2020-11-13 21:03:57 -03:00
parent e765c0fb14
commit f4dbc2646c
1 changed files with 9 additions and 6 deletions

View File

@ -980,13 +980,16 @@ class CSV extends Importer {
}
$this->save_mapping( $collection['id'], $collection['mapping'] );
$coll = \Tainacan\Repositories\Collections::get_instance()->fetch($collection['id']);
$metadata_order = array_map(
function($meta) { return ["enabled"=>true, "id"=>$meta]; },
array_keys( $collection['mapping'] )
);
$coll->set_metadata_order( $metadata_order );
if(empty($coll->get_metadata_order())) {
$metadata_order = array_map(
function($meta) { return ["enabled"=>true, "id"=>$meta]; },
array_keys( $collection['mapping'] )
);
$coll->set_metadata_order( $metadata_order );
}
if ( $coll->validate() ) {
\Tainacan\Repositories\Collections::get_instance()->update( $coll );
} else {