1

I'm trying to upgrade Magento 2.2.3 to Magento 2.4.4 and successfully composer updated the setup and have all other modules updated as well but while running setup:upgrade command, i got this error:

Unable to apply data patch Magento\Catalog\Setup\Patch\Data\UpdateMultiselectAttributesBackendTypes for module Magento_Catalog. Original exception message: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '109760-972-0' for key 'CATALOG_PRODUCT_ENTITY_TEXT_ENTITY_ID_ATTRIBUTE_ID_STORE_ID', query was: INSERT INTO `catalog_product_entity_text` (`value_id`,`attribute_id`,`store_id`,`entity_id`,`value`) VALUES (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?)

I tried to patch the vendor/magento/module-catalog/Setup/Patch/Data/UpdateMultiselectAttributesBackendTypes.php file using this solution Magento 2.4.4 error in setup:upgrade and yes this error was gone but the process stuck for forever on Module 'Magento_Catalog'. I tried several times but again and again same thing.

6
  • Try backing up the DB, then go to catalog_product_entity_text table and delete entry with entity_id = 109760, attribute_id = 972 and store_id = 0 Jun 2, 2022 at 20:57
  • yes i already did and after that one more shows up and so on but there is no duplicates there in the existing table.
    – Cv Gandhi
    Jun 3, 2022 at 2:55
  • @CvK, any idea how you resolved this issue as I am running into the same issue? I want to avoid making changes to out of the box code if possible.
    – cnu
    Sep 10, 2022 at 22:43
  • have you solved it @CvGandhi Jun 29, 2023 at 12:31
  • used this magento.stackexchange.com/questions/355539/… but i dumped the conflicting rows.
    – Cv Gandhi
    Jun 30, 2023 at 13:04

2 Answers 2

2

I just had the same issue and the following solution helped me. Try to replace

        foreach (array_chunk($dataToMigrate, 2000) as $dataChunk) {
            $connection->insertMultiple($textTable, $dataChunk);
        }

with

        foreach (array_chunk($dataToMigrate, 500) as $dataChunk) {
            try {
                $connection->insertMultiple($textTable, $dataChunk);
            } catch (\Exception $e) {
                foreach($dataChunk as $single) {
                    $connection->insertOnDuplicate($textTable, $dataChunk);
                }
            }
        }

File: vendor/magento/module-catalog/Setup/Patch/Data/UpdateMultiselectAttributesBackendTypes.php Line ~90.

4
  • Is this a known bug or none else reported this so far since you're suggesting to make changes to out of box code here?
    – cnu
    Sep 10, 2022 at 22:45
  • hi @cnu have you find any solution? Jun 29, 2023 at 12:53
  • @Kishor6ugani no, as a quick fix modified out of the box code for testing the upgrade.
    – cnu
    Jul 2, 2023 at 3:09
  • can you share that code ? @cnu Jul 3, 2023 at 5:18
0

Did anybody fix this, we're upgrading from 2.4.5 to 2.4.6 and getting the same issue. We the code linked to by post and the extra code in this thread it just hangs on 'Magento_Catalog'.

1
  • have you solved it , I am facing same issue Jun 29, 2023 at 12:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.