Skip to content
This repository has been archived by the owner on Apr 29, 2019. It is now read-only.

Duplicate multiselect values result in Product EAV indexing errors #103

Closed
tdgroot opened this issue Mar 27, 2018 · 6 comments
Closed

Duplicate multiselect values result in Product EAV indexing errors #103

tdgroot opened this issue Mar 27, 2018 · 6 comments
Assignees

Comments

@tdgroot
Copy link
Contributor

tdgroot commented Mar 27, 2018

Preconditions

  1. Magento 2.2.2

Steps to reproduce

  1. Create a multiselect attribute, fill it with values
  2. Create an import sheet with a column for the multiselect attribute
  3. Fill in duplicate values, for example Dutch|English|French|Chinese|English.
  4. Import the sheet.

Expected result

$ bin/magento indexer:reindex
Design Config Grid index has been rebuilt successfully in 00:00:00
Customer Grid index has been rebuilt successfully in 00:00:00
Product Flat Data index has been rebuilt successfully in 00:00:00
Category Flat Data index has been rebuilt successfully in 00:00:00
Category Products index has been rebuilt successfully in 00:00:00
Product Categories index has been rebuilt successfully in 00:00:00
Product Price index has been rebuilt successfully in 00:00:00
Product EAV index has been rebuilt successfully in 00:00:00
Catalog Search index has been rebuilt successfully in 00:00:02
Stock index has been rebuilt successfully in 00:00:00
Catalog Rule Product index has been rebuilt successfully in 00:00:00
Catalog Product Rule index has been rebuilt successfully in 00:00:00
Amasty Customer Group Catalog Rule index has been rebuilt successfully in 00:00:00
Amasty Customer Group Catalog Rule index has been rebuilt successfully in 00:00:00
Amasty Customer Group Catalog Rule index has been rebuilt successfully in 00:00:00
Search Spell-Correction index has been rebuilt successfully in 00:00:00

Actual result

$ bin/magento indexer:reindex
Design Config Grid index has been rebuilt successfully in 00:00:00
Customer Grid index has been rebuilt successfully in 00:00:00
Product Flat Data index has been rebuilt successfully in 00:00:00
Category Flat Data index has been rebuilt successfully in 00:00:00
Category Products index has been rebuilt successfully in 00:00:00
Product Categories index has been rebuilt successfully in 00:00:00
Product Price index has been rebuilt successfully in 00:00:00
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '877-146-1-170-877' for key 'PRIMARY', query was: INSERT INTO `catalog_product_index_eav_temp` (`entity_id`,`attribute_id`,`store_id`,`value`,`source_id`) VALUES ...
Catalog Search index has been rebuilt successfully in 00:00:00
Stock index has been rebuilt successfully in 00:00:00
Catalog Rule Product index has been rebuilt successfully in 00:00:00
Catalog Product Rule index has been rebuilt successfully in 00:00:00
Amasty Customer Group Catalog Rule index has been rebuilt successfully in 00:00:00
Amasty Customer Group Catalog Rule index has been rebuilt successfully in 00:00:00
Amasty Customer Group Catalog Rule index has been rebuilt successfully in 00:00:00
Search Spell-Correction index has been rebuilt successfully in 00:00:00

The solution

I see 2 possible solutions:

  • Deduplicate the values while importing the file.
  • Add an error while validating the file.

I created a plugin to fix it for now:

<?php

namespace Marissen\MagentoCatalogImportExport\Plugin\Model\Import;

use Magento\CatalogImportExport\Model\Import\Product as Subject;

class Product
{
    public function afterParseMultiselectValues(Subject $subject, array $values): array
    {
        return array_unique($values);
    }
}
@tdgroot
Copy link
Contributor Author

tdgroot commented Mar 27, 2018

I added The solution section to get the discussion going, so we can get to a solution faster.

magento-engcom-team pushed a commit that referenced this issue Apr 13, 2018
Eliminate usage of Zend_Config from Magento 2 Open Source #71
@dmanners
Copy link
Contributor

Hi @tdgroot I think that adding the deduplication of values would be a valid fix in this case.

@dmanners
Copy link
Contributor

Actually talking with @pogster we think that maybe showing this error message would be a good option here.

@pogster if you feel like tackling this at some point feel free to assign it to yourself.

@pogster pogster self-assigned this Jul 6, 2018
pogster added a commit to pogster/import-export-improvements that referenced this issue Jul 14, 2018
pogster added a commit to pogster/import-export-improvements that referenced this issue Jul 17, 2018
pogster added a commit to pogster/import-export-improvements that referenced this issue Jul 18, 2018
pogster added a commit to pogster/import-export-improvements that referenced this issue Jul 18, 2018
magento-engcom-team added a commit that referenced this issue Jul 20, 2018
 - Merge Pull Request magento/graphql-ce#103 from magento/graphql-ce:25_hide_product_attributes
 - Merged commits:
   1. 7f9d1bc
   2. 8f92ef4
@pogster
Copy link
Contributor

pogster commented Jul 22, 2018

PR is open #117

@dmanners
Copy link
Contributor

Hi, this has been covered in the 2.3-develop branch by the PR #117 from @pogster

@tdgroot
Copy link
Contributor Author

tdgroot commented Jul 27, 2018

Great work, thanks @pogster and @dmanners!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants