Block empty values in csv importer (#221)
This commit is contained in:
parent
48cc148f2d
commit
923ab57915
|
@ -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' ) {
|
||||
|
@ -649,6 +651,18 @@ class CSV extends Importer {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
|
|
Loading…
Reference in New Issue