diff --git a/app/code/Magento/CustomerImportExport/Model/Import/Customer.php b/app/code/Magento/CustomerImportExport/Model/Import/Customer.php index bee4479526037..016dca2fa526c 100644 --- a/app/code/Magento/CustomerImportExport/Model/Import/Customer.php +++ b/app/code/Magento/CustomerImportExport/Model/Import/Customer.php @@ -270,13 +270,29 @@ protected function _saveCustomerEntities(array $entitiesToCreate, array $entitie $this->_connection->insertOnDuplicate( $this->_entityTable, $entitiesToUpdate, - $this->customerFields + $this->getCustomerEntityFieldsToUpdate($entitiesToUpdate) ); } return $this; } + /** + * Filter the entity that are being updated so we only change fields found in the importer file + * + * @param array $entitiesToUpdate + * @return array + */ + private function getCustomerEntityFieldsToUpdate(array $entitiesToUpdate): array + { + $firstCustomer = reset($entitiesToUpdate); + $columnsToUpdate = array_keys($firstCustomer); + $customerFieldsToUpdate = array_filter($this->customerFields, function ($field) use ($columnsToUpdate) { + return in_array($field, $columnsToUpdate); + }); + return $customerFieldsToUpdate; + } + /** * Save customer attributes. *