Magento2: Customer Import - Invalid data for insert

Created on 25 Apr 2016  路  16Comments  路  Source: magento/magento2

Steps to reproduce

  1. Create CSV file for customer import with two rows: first - all columns filled with dummy content, second - without gender or dob data (example attached).
    test_main.csv.zip
  2. Choose "Customers Main File", "Add/Update Complex Data" options.
  3. Hit "Check Data" button - validation should be OK.
  4. Hit "Import" button.

    Expected result

  5. Customer data imported to the shop.

    Actual result

  6. Error message appears: "Invalid data for insert".

P. S. Error occurs because data rows which are going to be inserted have different keys (https://github.com/magento/magento2/blob/develop/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php#L1878). It happens because fields with empty values are discarded during data preparation step (https://github.com/magento/magento2/blob/develop/app/code/Magento/CustomerImportExport/Model/Import/Customer.php#L373). I was able to import data just commenting these lines, but obviously it requires more proper fix.

ImportExport Format is not valid Ready for Work bug report

Most helpful comment

This is still an issue in v2.1.3

All 16 comments

@ilol please review

Hi @zinittest

Thank you for reporting.
We've created an internal ticket MAGETWO-58316 to resolve this issue.

Hi @BaDos

Any updates - i am facing same issue with importing customers-address data

Hi @EL-Nazer

We are working on this issue.

This is still an issue in v2.1.3

Please add this fix in v2.1.4. This is critical! Original date reported is 25 Apr 2016. Fix was at 28 Sep 2016. Today 17 Jan 2017... #crying

PS: Fix from @mmansoorebay is working. Edited the core...

I'm still facing this issue in v2.1.3 (customer composite).
@PieterCappelle : Which commit you use to fix? 8abf097 or 487ae24

@nntoan Both.

@PieterCappelle You can choose only one commit. Because one of them add new lines to the if statement and the other one will delete the whole if statement...

Both of them mean you add new line, then you delete the whole if => only 487ae24
I tried 487ae24 and it's not working actually.

Actually 487ae24 (removing the if statement) solved the issue for me. The question is why this commit hasnt been merged with the 2.1 branch. Therefore the fix is not live.

The issue is still there in v2.1.5. Commit https://github.com/magento/magento2/commit/487ae24056c189c63eb4427f2a5858890544e092 fixed the issue for me.

This issue has already been fixed. Internal ticket for ver. 2.1. - MAGETWO-58760.
Internal ticket for ver. 2.0 - MAGETWO-58392.
These fixes should be available in some of the nearest release.

@apshahi please check latest stable version before commenting, fix should be present in 2.1.8 due to https://github.com/magento/magento2/commit/aaf85037b4db866b04ceed183578110ce1403e2c.

@orlangur, I 'm not exactally getting your point. The question is which Section in commenting in code.

@apshahi I don't see your comment I commented (or I commented in the wrong thread?).

AFAIR, there was something like "still see this on 2.1.7" while 2.1.8 was already released.

Using 2.2 This is still a problem. When uploading data matching the format of the sample file, get this error:
Header contains invalid attribute(s): "reward_update_notification", "reward_warning_notification"

M2 provides a sample file in the Import page, however, it provides an invalid file.
Also tried matching my import file to the customer main export in the Export page, but this does not work either (get a columns not matching rows error).

Was this page helpful?
0 / 5 - 0 ratings