Skip to content

Commit d6c6e66

Browse files
committed
Fix bug that deletes exiting customer entity Fields, if the columns are not present on Import file
1 parent 148da00 commit d6c6e66

File tree

1 file changed

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

1 file changed

+11
-1
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,13 +270,23 @@ 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+
private function getCustomerEntityFieldsToUpdate(array $entitiesToUpdate): array
281+
{
282+
$firstCustomer = reset($entitiesToUpdate);
283+
$columnsToUpdate = array_keys($firstCustomer);
284+
$customerFieldsToUpdate = array_filter($this->customerFields, function ($field) use ($columnsToUpdate) {
285+
return in_array($field, $columnsToUpdate);
286+
});
287+
return $customerFieldsToUpdate;
288+
}
289+
280290
/**
281291
* Save customer attributes.
282292
*

0 commit comments

Comments
 (0)