Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug: Customer import deletes exiting customer entity Fields #11968

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 11 additions & 1 deletion app/code/Magento/CustomerImportExport/Model/Import/Customer.php
Expand Up @@ -270,13 +270,23 @@ protected function _saveCustomerEntities(array $entitiesToCreate, array $entitie
$this->_connection->insertOnDuplicate(
$this->_entityTable,
$entitiesToUpdate,
$this->customerFields
$this->getCustomerEntityFieldsToUpdate($entitiesToUpdate)
);
}

return $this;
}

private function getCustomerEntityFieldsToUpdate(array $entitiesToUpdate): array
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you maybe a docblock to this method with a short explanation of the bug this method fixes. Is there actually a github issue for this fix cause you could add a link to that here.

{
$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.
*
Expand Down