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

Magento_ImportExport: Running multiple product imports after each other can create faulty duplicate sku's #8235

Closed
koenner01 opened this issue Jan 23, 2017 · 1 comment
Assignees
Labels
bug report Component: ImportExport Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed

Comments

@koenner01
Copy link
Contributor

When running multiple product imports through the importExport module of Magento, duplicate sku's can be generated during the import process because of the SkuProcessor model being used as a singleton.

Preconditions

  1. MG 2.1.2 or MG 2.1.3
  2. PHP7.0

Steps to reproduce

  1. create a Magento\ImportExport\Model\Import model in a loop
  2. run multiple product imports with more than 50 products in the data with behaviour 'append'
    As a test we are running an import with 100 products without their relations (related, upsell, crosssell) and then an import with the same 100 sku's but only with their relations.

Expected result

  1. 100 products should've been created in Magento

Actual result

  1. More than 100 products are created in Magento (double sku's were created!)

I've traced this issue back to Magento\CatalogImportExport\Model\Import\Product instantiating it's skuProcessor through the constructor as a singleton. Because it is a singleton, the oldSkus on the skuProcessor object aren't being reloaded in between the imports.

Currently we are working around this by instantiating the skuProcessor in our custom Model constructor

protected $skuProcessor;

public function __construct(
    ...
    \Magento\CatalogImportExport\Model\Import\Product\SkuProcessor $skuProcessor
) {
    ...
    $this->skuProcessor = $skuProcessor;
    ...
}

And then in the for loop we reload the oldSkus by doing

for (...) {
    $this->skuProcessor->reloadOldSkus();
    ...
    $importerModel = $this->importerModelFactory->create();
    ...
}

Because the skuProcessor is being treated as a singleton, the oldSku's in Magento\CatalogImportExport\Model\Import\Product will be correct

@piotrekkaminski
Copy link
Contributor

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

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: Format is valid Gate 1 Passed. Automatic verification of issue format passed
Projects
None yet
Development

No branches or pull requests

4 participants