Skip to content

When updating customers through CustomerImportExport fields thats are not set in importdata will be nullified #8548

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

Closed
rvr31 opened this issue Feb 14, 2017 · 2 comments
Labels
bug report Component: ImportExport Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@rvr31
Copy link

rvr31 commented Feb 14, 2017

When using module-customer-import-export/Model/Import/Customer.php to update existing customers, attributes that are in customer_entity and are not in the data to update will be nullified. For instance, updating customer name and or group through the importer would empty that customers password / rp_roken etc. This happens because in the _saveCustomerEntities function all fields of the customer are passed to insertOnDuplicate function.

Preconditions

  1. Magento version 2.1.4

Steps to reproduce

  1. Update a existing customer with not all fields specified ie: just email and name or group_id through module-customer-import-export/Model/Import/Customer.php

Expected result

  1. Attributes that are not in update data should not be updated

Actual result

  1. Attributes that where not in the update data are nullified.

Resolution

In the function call on vendor/magento/module-customer-import-export/Model/Import/Customer.php:264 $this->customerFields should not be passed to the insertOnDuplicate function. The logic of insertOnDuplicate would then automatically build the query for the fields that are actually in the update data.

Query that now is beeging generated when updating customers:(group_id,store_id,created_at,updated_at,entity_id,firstname,lastname,gender,email):

INSERT INTO `customer_entity` (`group_id`,`store_id`,`created_at`,`updated_at`,`entity_id`,`firstname`,`lastname`,`gender`,`email`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE `group_id` = VALUES(`group_id`), `store_id` = VALUES(`store_id`), `updated_at` = VALUES(`updated_at`), `created_at` = VALUES(`created_at`), `created_in` = VALUES(`created_in`), `prefix` = VALUES(`prefix`), `firstname` = VALUES(`firstname`), `middlename` = VALUES(`middlename`), `lastname` = VALUES(`lastname`), `suffix` = VALUES(`suffix`), `dob` = VALUES(`dob`), `password_hash` = VALUES(`password_hash`), `taxvat` = VALUES(`taxvat`), `confirmation` = VALUES(`confirmation`), `gender` = VALUES(`gender`), `rp_token` = VALUES(`rp_token`), `rp_token_created_at` = VALUES(`rp_token_created_at`), `failures_num` = VALUES(`failures_num`), `first_failure` = VALUES(`first_failure`), `lock_expires` = VALUES(`lock_expires`)

Query that should have been generated when updating customersgroup_id,store_id,created_at,updated_at,entity_id,firstname,lastname,gender,email:

INSERT INTO `customer_entity` (`group_id`,`store_id`,`created_at`,`updated_at`,`entity_id`,`firstname`,`lastname`,`gender`,`email`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?), (?, ?, ?, ?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE `group_id` = VALUES(`group_id`), `store_id` = VALUES(`store_id`), `created_at` = VALUES(`created_at`), `updated_at` = VALUES(`updated_at`), `entity_id` = VALUES(`entity_id`), `firstname` = VALUES(`firstname`), `lastname` = VALUES(`lastname`), `gender` = VALUES(`gender`), `email` = VALUES(`email`)
@magento-engcom-team magento-engcom-team added 2.1.x bug report Component: ImportExport Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed and removed G1 Passed labels Sep 5, 2017
@magento-engcom-team magento-engcom-team added the Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed label Oct 9, 2017
@magento-engcom-team
Copy link
Contributor

@Robin31, thank you for your report.
We've created internal ticket(s) MAGETWO-81270 to track progress on the issue.

@magento-engcom-team magento-engcom-team added 2.2.x Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Oct 11, 2017
@piotrekkaminski
Copy link
Contributor

This issue was moved to magento-engcom/import-export-improvements#45

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Component: ImportExport Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests

4 participants