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

Duplicated & missing product rows in system product export #4531

Closed
wbyrnetx opened this issue May 16, 2016 · 13 comments
Closed

Duplicated & missing product rows in system product export #4531

wbyrnetx opened this issue May 16, 2016 · 13 comments
Labels
bug report Component: ImportExport Fixed in 2.2.x The issue has been fixed in 2.2 release line Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development

Comments

@wbyrnetx
Copy link
Contributor

wbyrnetx commented May 16, 2016

Steps to reproduce

  1. Install Magento from 2.0.2 tag (the one we tested on, but likely affects all versions).
  2. Create/import enough products so that when running an export, the main product query will have to use offsets to batch the results
  3. Look at the CSV and you will find duplicated product entries and some products that are missing altogether. From my testing, the total count is always correct and matches a SELECT COUN(*) FROM catalog_product_entity.

I spent some time looking into what may be causing this, and I believe it has to do with the ORDER BY has_options clause in the MySQL query. What I'm not sure about, is why the Magento export orders by that field in the first place.

When combining that ORDER BY with an OFFSET, the MySQL result order is inconsistent.

This can be observed by running the following queries against the Magento2 sample database.

  1. Query the first 10 products
    SELECT entity_id, sku FROM catalog_product_entity AS e ORDER BY e.has_options ASC LIMIT 10;

  2. Query the first 20 products
    SELECT entity_id, sku FROM catalog_product_entity AS e ORDER BY e.has_options ASC LIMIT 20;

If you compare the result set... you'll see what I'm talking about. For me, the first row in query 1 has entity_id 9347. In query 2, the first row has entity_id 90. Once you introduce offsetting the results, you get the same problem.

My proposed solution would be to order by entity_id in the export query, as that will always produce consistent result ordering, even with limits and offsets. This would require a change in Magento\CatalogImportExport\Model\Export\Product:: export

However, without knowing why it's sorted by has_options in the first place, I can't be sure.

@wbyrnetx wbyrnetx changed the title Duplicated & missing product rows in system order export Duplicated & missing product rows in system product export May 16, 2016
@vkorotun vkorotun removed the MX label Aug 4, 2016
@BaDos BaDos self-assigned this Sep 13, 2016
@BaDos
Copy link
Contributor

BaDos commented Sep 13, 2016

Hi @wbyrnetx

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

@BaDos BaDos added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development 2.0.x labels Sep 13, 2016
@BaDos BaDos removed their assignment Sep 13, 2016
@BaDos BaDos added the develop label Sep 14, 2016
mmansoor-magento pushed a commit that referenced this issue Sep 23, 2016
Fixed issues:
* MAGETWO-57820: [GITHUB] php bin/magento i18n:pack creates unwanted dir #6260
Bug - P1
* MAGETWO-58337: [Github] Duplicated & missing product rows in system product export #4531
* MAGETWO-58289: [Github] Product URL Key not automatically generating during import #5128
* MAGETWO-58134: [GitHub] Products became “out of stock” after update from 2.0.7 to 2.1.0 #5222
* MAGETWO-58132: [GitHub] module:uninstall can remove code it uses itself #5797
* MAGETWO-58236: Sync requirements of composer.json of Sample-data with mainline
@Ctucker9233
Copy link

I've just noticed this prolem in 2.1.1. Seems to happen to random products. Looking at the product entity table I can't see the duplications where they show in the exported .csv. @mmansoorebay does this commit fix this problem in 2.1.1 or is there a patch pending?

@wujashek
Copy link
Contributor

wujashek commented Feb 2, 2017

+1 Looking forward for this issue to be resolved.

@harimayco
Copy link

harimayco commented Feb 9, 2017

+1 i'm also facing this issue in magento 2.1.3.

@jontay27
Copy link

+1, Will this be resolved soon?

@ScottBadger
Copy link

I'm seeing the same thing as harimayco, and when I remove the duplicate rows, make my edits and re-import, I get a "Number of columns does not correspond to the number of rows in the header" error. I also tried copying the non-duplicate rows into another csv, made the edits there and imported but got the same error. Any way to use the "good" rows from the export in an import? Also, I can export/import other product's variations without a problem,, and no real difference that I can see with those I can't..... Anybody know why some products work and others don't? Thanks, Scott

@ScottBadger
Copy link

So.... for me at least, it turned out to be an ampersand in the descriptions (see http://stackoverflow.com/questions/39906595/sign-in-magento-2-0-product-import-is-causing-errors ). Changed the "&" to "and" and voila!...no dupes in the export. Made my edits and imported without errors.. Scott

@jaredchu
Copy link

So "&" character cause this issue, has anyone solution for it?

@jaredchu
Copy link

jaredchu commented Apr 14, 2017

we found that _ character in product image also cause this issue

@harimayco
Copy link

@jaredchu fix for duplicate product in export #7350

@veloraven
Copy link
Contributor

This issue was fixed for develop branch.
Internal ticket for ver. 2.0 - MAGETWO-62439
Internal ticker for ver. 2.1 - MAGETWO-58548

@magento-engcom-team magento-engcom-team added 2.0.x Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development labels Sep 11, 2017
@magento-engcom-team magento-engcom-team added bug report develop Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Component: ImportExport labels Sep 11, 2017
@magento-engcom-team
Copy link
Contributor

@wbyrnetx thank you for your report.
The fix for this issue is already fixed in 2.2.0 release

@magento-engcom-team magento-engcom-team added the Fixed in 2.2.x The issue has been fixed in 2.2 release line label Sep 20, 2017
@simonmaass
Copy link

I am having the exact same problem as described above! I am using magento 2.2.5!

The only difference that i can see between the products that exportet fine and the ones that have dublicates is the field "custom_options" - it looks like prducts with custom options get wrong export with dublicate products

image

taskula pushed a commit to Hypernova-Oy/magento2 that referenced this issue Jul 29, 2019
[honey] MC-17015: [GraphQL] Product Categories query doesn't return all categories where product is visible
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Component: ImportExport Fixed in 2.2.x The issue has been fixed in 2.2 release line Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development
Projects
None yet
Development

No branches or pull requests