Skip to content

Conversation

@mimarcel
Copy link
Contributor

@mimarcel mimarcel commented Aug 29, 2016

This PR fixes issue described in #5780.

Preconditions:

  • have latest M2.1 installed
  • install demo data (using bin/magento demodata installation options)

Issue:

Product import with more than 100 rows may result in duplicated products.

How to replicate:

  • Import a CSV file which has more than 100 rows where rows 100 and 101 belong to the same sku A (different values per store).
  • After running the import, you will realise that in importexport_importdata table, sku A will appear in two batches: in the first batch which contains the first 100 rows and in the 2nd batch which contains the next 100 rows (which includes row 101).

Expected:

  • Product with sku A is imported only once.

Actual:

  • The import does incorrectly identify product with SKU A as new in both batches and, as a consequence, it does duplicate the product.

Solution:

  • Product with SKU A should be inserted in the first batch (new product) and it should updated in the 2nd batch (existing product).
  • Note that the fix also changes the count of updated products following the idea:

A sku in a batch should be counted as an updated product only if this sku was not inserted or updated in a previous batch.

 Solution: Updating $oldSkus array after inserting new products in db.
Since the import works in batches of 100 products, it is needed to store which products were inserted/updated in previous batches.
@NadiyaS
Copy link
Contributor

NadiyaS commented Sep 16, 2016

Hi @mimarcel ,
the issue was already fixed and delivered to develop branch. See commits:
0b05d4d,
a4c7261,
d48f1e2,
0919256,
7796729.
I will close your PR.
Thank you for your contribution.

@NadiyaS NadiyaS closed this Sep 16, 2016
@mimarcel mimarcel deleted the fix/product_import_with_more_than_100_rows_may_result_in_duplicated_products branch June 27, 2017 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants