Skip to content

Commit f8144da

Browse files
author
Oleksii Korshenko
authored
MAGETWO-83310: Fix bug: Customer import deletes exiting customer entity Fields #11968
2 parents a7aa1e0 + 62e7e90 commit f8144da

File tree

1 file changed

+17
-1
lines changed
  • app/code/Magento/CustomerImportExport/Model/Import

1 file changed

+17
-1
lines changed

app/code/Magento/CustomerImportExport/Model/Import/Customer.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,13 +270,29 @@ protected function _saveCustomerEntities(array $entitiesToCreate, array $entitie
270270
$this->_connection->insertOnDuplicate(
271271
$this->_entityTable,
272272
$entitiesToUpdate,
273-
$this->customerFields
273+
$this->getCustomerEntityFieldsToUpdate($entitiesToUpdate)
274274
);
275275
}
276276

277277
return $this;
278278
}
279279

280+
/**
281+
* Filter the entity that are being updated so we only change fields found in the importer file
282+
*
283+
* @param array $entitiesToUpdate
284+
* @return array
285+
*/
286+
private function getCustomerEntityFieldsToUpdate(array $entitiesToUpdate): array
287+
{
288+
$firstCustomer = reset($entitiesToUpdate);
289+
$columnsToUpdate = array_keys($firstCustomer);
290+
$customerFieldsToUpdate = array_filter($this->customerFields, function ($field) use ($columnsToUpdate) {
291+
return in_array($field, $columnsToUpdate);
292+
});
293+
return $customerFieldsToUpdate;
294+
}
295+
280296
/**
281297
* Save customer attributes.
282298
*

0 commit comments

Comments
 (0)