diff --git a/src/importer/class-tainacan-csv.php b/src/importer/class-tainacan-csv.php index c6121a120..975338700 100644 --- a/src/importer/class-tainacan-csv.php +++ b/src/importer/class-tainacan-csv.php @@ -575,6 +575,8 @@ class CSV extends Importer { $tainacan_metadatum_id = array_search( $metadatum_source, $collection_definition['mapping'] ); $metadatum = $Tainacan_Metadata->fetch( $tainacan_metadatum_id ); + if( $this->is_empty_value( $values ) ) continue; + if( $metadatum instanceof Entities\Metadatum ) { $singleItemMetadata = new Entities\Item_Metadata_Entity( $item, $metadatum); // *empty item will be replaced by inserted in the next foreach if( $metadatum->get_metadata_type() == 'Tainacan\Metadata_Types\Taxonomy' ) { @@ -648,7 +650,19 @@ class CSV extends Importer { return false; } } - + + /** + * @param $value + * @return bool + */ + public function is_empty_value( $value ){ + if( is_array( $value ) ){ + return ( empty( array_filter( $value ) ) ); + } else { + return ( trim( $value ) === '' ); + } + } + /** * @param $metadatum the metadata * @param $values the categories names