@@ -667,8 +667,6 @@ protected function _prepareDataForUpdate(array $rowData): array
667
667
$ defaults [$ table ][$ customerId ][$ attributeCode ] = $ addressId ;
668
668
}
669
669
}
670
- // let's try to find region ID
671
- $ entityRow [self ::COLUMN_REGION_ID ] = null ;
672
670
673
671
if (!empty ($ entityRow [self ::COLUMN_REGION ]) && !empty ($ entityRow [self ::COLUMN_COUNTRY_ID ])) {
674
672
$ entityRow [self ::COLUMN_REGION_ID ] = $ this ->getCountryRegionId (
@@ -679,6 +677,8 @@ protected function _prepareDataForUpdate(array $rowData): array
679
677
$ entityRow [self ::COLUMN_REGION ] = $ entityRow [self ::COLUMN_REGION_ID ] !== null
680
678
? $ this ->_regions [$ entityRow [self ::COLUMN_REGION_ID ]]
681
679
: $ entityRow [self ::COLUMN_REGION ];
680
+ } elseif ($ newAddress ) {
681
+ $ entityRow [self ::COLUMN_REGION_ID ] = null ;
682
682
}
683
683
if ($ newAddress ) {
684
684
$ entityRowNew = $ entityRow ;
@@ -908,7 +908,7 @@ protected function _validateRowForUpdate(array $rowData, $rowNumber)
908
908
}
909
909
}
910
910
911
- if (isset ($ rowData [self ::COLUMN_COUNTRY_ID ])) {
911
+ if (! empty ($ rowData [self ::COLUMN_COUNTRY_ID ])) {
912
912
if (isset ($ rowData [self ::COLUMN_POSTCODE ])
913
913
&& !$ this ->postcodeValidator ->isValid (
914
914
$ rowData [self ::COLUMN_COUNTRY_ID ],
@@ -918,8 +918,7 @@ protected function _validateRowForUpdate(array $rowData, $rowNumber)
918
918
$ this ->addRowError (self ::ERROR_VALUE_IS_REQUIRED , $ rowNumber , self ::COLUMN_POSTCODE );
919
919
}
920
920
921
- if (isset ($ rowData [self ::COLUMN_REGION ])
922
- && !empty ($ rowData [self ::COLUMN_REGION ])
921
+ if (!empty ($ rowData [self ::COLUMN_REGION ])
923
922
&& count ($ this ->getCountryRegions ($ rowData [self ::COLUMN_COUNTRY_ID ])) > 0
924
923
&& null === $ this ->getCountryRegionId (
925
924
$ rowData [self ::COLUMN_COUNTRY_ID ],
0 commit comments