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'] );
|
$tainacan_metadatum_id = array_search( $metadatum_source, $collection_definition['mapping'] );
|
||||||
$metadatum = $Tainacan_Metadata->fetch( $tainacan_metadatum_id );
|
$metadatum = $Tainacan_Metadata->fetch( $tainacan_metadatum_id );
|
||||||
|
|
||||||
|
if( $this->is_empty_value( $values ) ) continue;
|
||||||
|
|
||||||
if( $metadatum instanceof Entities\Metadatum ) {
|
if( $metadatum instanceof Entities\Metadatum ) {
|
||||||
$singleItemMetadata = new Entities\Item_Metadata_Entity( $item, $metadatum); // *empty item will be replaced by inserted in the next foreach
|
$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' ) {
|
if( $metadatum->get_metadata_type() == 'Tainacan\Metadata_Types\Taxonomy' ) {
|
||||||
|
@ -648,7 +650,19 @@ class CSV extends Importer {
|
||||||
return false;
|
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 $metadatum the metadata
|
||||||
* @param $values the categories names
|
* @param $values the categories names
|
||||||
|
|
Loading…
Reference in New Issue