Migration Produkte von Shopware 5 Fehler: The language cannot be deleted because foreign key constraints exist - GELÖST

Ich habe aktuell ein Problem bei der Migration von Produkten aus Shopware 5 → Shopware 6. Es wurden knapp 53.000 Produkte korrekt migriert. Bei den letzten/aktuellsten ca. 2.000 Produkten in Shopware 5 schlägt die Migration allerdings fehl.

Es kommt folgender Fehler im Log:

[error] SWAG_MIGRATION_RUN_EXCEPTION
An exception occurred
Entity: product, sourceId: b4a75f0115184675bdade12c1e461a18
The language cannot be deleted because foreign key constraints exist.

In der Tabelle swag_migration_data stehen dann z.B. folgende Werte drin:
write_failure = 1

raw

{
  "detail": {
    "id": "68237",
    "articleID": "68237",
    "ordernumber": "71958",
    "suppliernumber": "6ES7390-1AF30-0AA0",
    "kind": "1",
    "additionaltext": null,
    "sales": "0",
    "active": "1",
    "instock": "1",
    "stockmin": "0",
    "laststock": "0",
    "weight": "0.650",
    "position": "0",
    "width": null,
    "height": null,
    "length": null,
    "ean": null,
    "unitID": null,
    "purchasesteps": null,
    "maxpurchase": null,
    "minpurchase": "1",
    "purchaseunit": null,
    "referenceunit": null,
    "packunit": null,
    "releasedate": null,
    "shippingfree": "0",
    "shippingtime": null,
    "purchaseprice": "11"
  },
  "id": "68237",
  "supplierID": "3",
  "name": "Siemens Simatic S7 Profilschiene 530mm 6ES7390-1AF30-0AA0",
  "description": null,
  "description_long": null,
  "shippingtime": null,
  "datum": "2022-09-12",
  "active": "1",
  "taxID": "1",
  "pseudosales": "0",
  "topseller": "0",
  "metaTitle": null,
  "keywords": null,
  "changetime": "2022-09-12 15:14:49",
  "pricegroupID": null,
  "pricegroupActive": "0",
  "filtergroupID": null,
  "laststock": "1",
  "crossbundlelook": "0",
  "notification": "0",
  "template": "",
  "mode": "0",
  "main_detail_id": "68237",
  "available_from": null,
  "available_to": null,
  "configurator_set_id": null,
  "tax": { "id": "1", "tax": "19.00", "description": "19%" },
  "attributes": {
    "id": "67812",
    "articleID": null,
    "articledetailsID": "68237",
    "attr1": "",
    "attr2": "",
    "attr3": "",
    "attr4": null,
    "attr5": null,
    "attr6": null,
    "attr7": null,
    "attr8": null,
    "attr9": null,
    "attr10": null,
    "attr11": null,
    "attr12": null,
    "attr13": null,
    "attr14": null,
    "attr15": null,
    "attr16": null,
    "attr17": null,
    "attr18": null,
    "attr19": null,
    "attr20": null,
    "dreisc_seo_url": "",
    "dreisc_seo_title": "",
    "dreisc_seo_title_replace": "0",
    "dreisc_seo_breadcrumb": "",
    "dreisc_canonical_link": "",
    "dreisc_robots_tag": "",
    "dreisc_facebook_description": "",
    "dreisc_twitter_description": "",
    "dreisc_facebook_image": "",
    "dreisc_twitter_image": "",
    "cbax_ebay_sync_instock": "1",
    "cbax_ebay_sync_price": "29",
    "pixup_exclude_sitemap": "0",
    "pixup_link_priority": null,
    "pixup_link_link_change_frequenzy": null,
    "viison_country_of_origin": "0",
    "viison_customs_tariff_number": "",
    "cbax_ebay_sync_variant": null,
    "z7_serial_number": "KXP8",
    "pickware_incoming_stock": "0",
    "pickware_physical_stock_for_sale": "1",
    "pickware_stock_management_disabled": "0",
    "pickware_stock_initialized": "1",
    "pickware_stock_initialization_time": "2022-09-12 15:14:49",
    "pickware_not_relevant_for_picking": "0",
    "pickware_wms_internal_picking_instructions": null,
    "viison_moss": null,
    "viison_other_service_paragraph_one_or_two": null,
    "viison_datev_cost_center": ""
  },
  "manufacturer": {
    "id": "3",
    "name": "Siemens",
    "img": "media/image/siemens.png",
    "link": "",
    "description": "",
    "meta_title": "Siemens",
    "meta_description": "",
    "meta_keywords": "",
    "changed": "2018-10-23 15:57:03",
    "media": {
      "id": "46191",
      "albumID": "-12",
      "name": "siemens",
      "description": "",
      "path": "media/image/siemens.png",
      "type": "IMAGE",
      "extension": "png",
      "file_size": "3844",
      "width": "300",
      "height": "71",
      "userID": "53",
      "created": "2018-09-27",
      "uri": "https://backend.eska-welt.de/media/image/4c/72/a2/siemens.png"
    },
    "attributes": {
      "id": "4",
      "supplierID": "3",
      "pixup_exclude_sitemap": "0",
      "pixup_link_priority": null,
      "pixup_link_link_change_frequenzy": null,
      "z7_supplier_seo_url": "siemens",
      "z7_supplier_seo_h1": "Artikel von Siemens"
    }
  },
  "_locale": "de-DE",
  "assets": [
    {
      "id": "325338",
      "articleID": "68237",
      "img": "Zesi7VNXzDMg8Y",
      "main": "1",
      "description": "upload from app",
      "position": "0",
      "width": "0",
      "height": "0",
      "relations": "",
      "extension": "jpg",
      "parent_id": null,
      "article_detail_id": null,
      "media_id": "351767",
      "media": {
        "id": "351767",
        "albumID": "-1",
        "name": "Zesi7VNXzDMg8Y",
        "description": "upload from app",
        "path": "media/image/Zesi7VNXzDMg8Y.jpg",
        "type": "IMAGE",
        "extension": "jpg",
        "file_size": "112866",
        "width": "1425",
        "height": "873",
        "userID": "106",
        "created": "2022-09-12",
        "attributes": { "id": "265519", "mediaID": "351767" },
        "uri": "https://backend.eska-welt.de/media/image/4e/a7/4a/Zesi7VNXzDMg8Y.jpg"
      }
    },
    {
      "id": "325339",
      "articleID": "68237",
      "img": "2QgTSxGU7jbMMSz",
      "main": "2",
      "description": "upload from app",
      "position": "0",
      "width": "0",
      "height": "0",
      "relations": "",
      "extension": "jpg",
      "parent_id": null,
      "article_detail_id": null,
      "media_id": "351766",
      "media": {
        "id": "351766",
        "albumID": "-1",
        "name": "2QgTSxGU7jbMMSz",
        "description": "upload from app",
        "path": "media/image/2QgTSxGU7jbMMSz.jpg",
        "type": "IMAGE",
        "extension": "jpg",
        "file_size": "71653",
        "width": "1234",
        "height": "851",
        "userID": "106",
        "created": "2022-09-12",
        "attributes": { "id": "265518", "mediaID": "351766" },
        "uri": "https://backend.eska-welt.de/media/image/20/g0/3d/2QgTSxGU7jbMMSz.jpg"
      }
    },
    {
      "id": "325340",
      "articleID": "68237",
      "img": "9kVtu5RYP14muUw",
      "main": "2",
      "description": "upload from app",
      "position": "0",
      "width": "0",
      "height": "0",
      "relations": "",
      "extension": "jpg",
      "parent_id": null,
      "article_detail_id": null,
      "media_id": "351764",
      "media": {
        "id": "351764",
        "albumID": "-1",
        "name": "9kVtu5RYP14muUw",
        "description": "upload from app",
        "path": "media/image/9kVtu5RYP14muUw.jpg",
        "type": "IMAGE",
        "extension": "jpg",
        "file_size": "41009",
        "width": "731",
        "height": "977",
        "userID": "106",
        "created": "2022-09-12",
        "attributes": { "id": "265516", "mediaID": "351764" },
        "uri": "https://backend.eska-welt.de/media/image/83/a5/cf/9kVtu5RYP14muUw.jpg"
      }
    },
    {
      "id": "325341",
      "articleID": "68237",
      "img": "ZwrxufH0JxMPoY",
      "main": "2",
      "description": "upload from app",
      "position": "0",
      "width": "0",
      "height": "0",
      "relations": "",
      "extension": "jpg",
      "parent_id": null,
      "article_detail_id": null,
      "media_id": "351765",
      "media": {
        "id": "351765",
        "albumID": "-1",
        "name": "ZwrxufH0JxMPoY",
        "description": "upload from app",
        "path": "media/image/ZwrxufH0JxMPoY.jpg",
        "type": "IMAGE",
        "extension": "jpg",
        "file_size": "58923",
        "width": "1409",
        "height": "546",
        "userID": "106",
        "created": "2022-09-12",
        "attributes": { "id": "265517", "mediaID": "351765" },
        "uri": "https://backend.eska-welt.de/media/image/a9/fb/03/ZwrxufH0JxMPoY.jpg"
      }
    },
    {
      "id": "325342",
      "articleID": "68237",
      "img": "Z61ZOq9EGMK13t",
      "main": "2",
      "description": "upload from app",
      "position": "0",
      "width": "0",
      "height": "0",
      "relations": "",
      "extension": "jpg",
      "parent_id": null,
      "article_detail_id": null,
      "media_id": "351768",
      "media": {
        "id": "351768",
        "albumID": "-1",
        "name": "Z61ZOq9EGMK13t",
        "description": "upload from app",
        "path": "media/image/Z61ZOq9EGMK13t.jpg",
        "type": "IMAGE",
        "extension": "jpg",
        "file_size": "231087",
        "width": "1224",
        "height": "720",
        "userID": "106",
        "created": "2022-09-12",
        "attributes": { "id": "265520", "mediaID": "351768" },
        "uri": "https://backend.eska-welt.de/media/image/fa/12/fe/Z61ZOq9EGMK13t.jpg"
      }
    }
  ],
  "categories": [
    { "id": "430", "path": "|3|" },
    { "id": "438", "path": "|437|" }
  ],
  "prices": [
    {
      "id": "87050",
      "pricegroup": "EK",
      "from": "1",
      "to": "beliebig",
      "articleID": "68237",
      "articledetailsID": "68237",
      "price": "24.36974789916",
      "pseudoprice": "0",
      "baseprice": null,
      "percent": "0.00",
      "customergroup": {
        "id": "1",
        "groupkey": "EK",
        "description": "Shopkunden",
        "tax": "1",
        "taxinput": "1",
        "mode": "0",
        "discount": "0",
        "minimumorder": "10",
        "minimumordersurcharge": "5"
      },
      "currencyShortName": "EUR"
    }
  ],
  "shops": ["7", "1"]
}

converted

{
  "id": "b4a75f0115184675bdade12c1e461a18",
  "manufacturer": {
    "id": "4e827f37bb7c4f3cb0519026b6829ddc",
    "name": "Siemens",
    "media": {
      "id": "670d9c8cb089494288309f5ac47d5563",
      "mediaFolderId": "e3acb88a86f1463cba125d72556bdf2e"
    },
    "customFields": {
      "migration_eska-weltde_product_manufacturer_pixup_exclude_sitemap": false,
      "migration_eska-weltde_product_manufacturer_z7_supplier_seo_url": "siemens",
      "migration_eska-weltde_product_manufacturer_z7_supplier_seo_h1": "Artikel von Siemens"
    }
  },
  "tax": {
    "id": "650884ce1dd545ecab972d7bf0cb38c9",
    "taxRate": 19.0,
    "name": "19%"
  },
  "price": [
    {
      "currencyId": "b7d2554b0ce847cd82f3ac9bd1c0dfca",
      "gross": 29.0,
      "net": 24.36974789916,
      "linked": true
    }
  ],
  "prices": [
    {
      "id": "01634e6dee5c40f59ed8bfc62dd0fbf5",
      "productId": "b4a75f0115184675bdade12c1e461a18",
      "rule": {
        "id": "4f4ebc637cd742279f97ab0eba5a872f",
        "name": "Shopkunden",
        "priority": 0,
        "moduleTypes": { "types": ["price"] },
        "conditions": [
          {
            "id": "068ee029af544b0495e95ff3942e91ce",
            "type": "orContainer",
            "value": []
          },
          {
            "id": "ccd41b2925da430882896b0b5458eddd",
            "type": "andContainer",
            "parentId": "068ee029af544b0495e95ff3942e91ce",
            "value": []
          },
          {
            "id": "665e8d9d070642d89bc8c95be4df07d8",
            "type": "customerCustomerGroup",
            "parentId": "ccd41b2925da430882896b0b5458eddd",
            "position": 1,
            "value": {
              "customerGroupIds": ["85233c319857462598932e6be2f96ed6"],
              "operator": "="
            }
          }
        ]
      },
      "price": [
        {
          "currencyId": "b7d2554b0ce847cd82f3ac9bd1c0dfca",
          "gross": 29.0,
          "net": 24.36974789916,
          "linked": true
        }
      ],
      "quantityStart": 1,
      "quantityEnd": null
    }
  ],
  "media": [
    {
      "id": "8cd9ce7ad01d4e7a9e17c8c01dedd673",
      "productId": "b4a75f0115184675bdade12c1e461a18",
      "position": 0,
      "media": {
        "id": "71f431ececfb43429c91032a02e7f0e2",
        "title": "Zesi7VNXzDMg8Y",
        "alt": "upload from app",
        "mediaFolderId": "26d79f33c64f4f418a785d5227bb2818"
      }
    },
    {
      "id": "c122752d048e47979f1c26e83fe6c6c6",
      "productId": "b4a75f0115184675bdade12c1e461a18",
      "position": 0,
      "media": {
        "id": "c93e1b80122a4b06a681220c0f54f73a",
        "title": "2QgTSxGU7jbMMSz",
        "alt": "upload from app",
        "mediaFolderId": "26d79f33c64f4f418a785d5227bb2818"
      }
    },
    {
      "id": "de581e6fdd164acbbeaebe3a61225caa",
      "productId": "b4a75f0115184675bdade12c1e461a18",
      "position": 0,
      "media": {
        "id": "590e1a13bca64ad1975fa535c92724bc",
        "title": "9kVtu5RYP14muUw",
        "alt": "upload from app",
        "mediaFolderId": "26d79f33c64f4f418a785d5227bb2818"
      }
    },
    {
      "id": "79fdb79ca91b4a13b37b594579dbe1e5",
      "productId": "b4a75f0115184675bdade12c1e461a18",
      "position": 0,
      "media": {
        "id": "56dce9fa89f048438afc381b93617933",
        "title": "ZwrxufH0JxMPoY",
        "alt": "upload from app",
        "mediaFolderId": "26d79f33c64f4f418a785d5227bb2818"
      }
    },
    {
      "id": "a4816b5ac4f54b47875f369c2c76ee22",
      "productId": "b4a75f0115184675bdade12c1e461a18",
      "position": 0,
      "media": {
        "id": "ae17d8532334436b9fd670b9f9044752",
        "title": "Z61ZOq9EGMK13t",
        "alt": "upload from app",
        "mediaFolderId": "26d79f33c64f4f418a785d5227bb2818"
      }
    }
  ],
  "cover": {
    "id": "8cd9ce7ad01d4e7a9e17c8c01dedd673",
    "productId": "b4a75f0115184675bdade12c1e461a18",
    "position": 0,
    "media": {
      "id": "71f431ececfb43429c91032a02e7f0e2",
      "title": "Zesi7VNXzDMg8Y",
      "alt": "upload from app",
      "mediaFolderId": "26d79f33c64f4f418a785d5227bb2818"
    }
  },
  "name": "Siemens Simatic S7 Profilschiene 530mm 6ES7390-1AF30-0AA0",
  "customFields": {
    "migration_eska-weltde_product_dreisc_seo_title_replace": false,
    "migration_eska-weltde_product_cbax_ebay_sync_instock": 1,
    "migration_eska-weltde_product_cbax_ebay_sync_price": 29.0,
    "migration_eska-weltde_product_pixup_exclude_sitemap": false,
    "migration_eska-weltde_product_viison_country_of_origin": "0",
    "migration_eska-weltde_product_z7_serial_number": "KXP8",
    "migration_eska-weltde_product_pickware_incoming_stock": "0",
    "migration_eska-weltde_product_pickware_physical_stock_for_sale": "1",
    "migration_eska-weltde_product_pickware_stock_management_disabled": "0",
    "migration_eska-weltde_product_pickware_stock_initialized": "1",
    "migration_eska-weltde_product_pickware_stock_initialization_time": "2022-09-12 15:14:49",
    "migration_eska-weltde_product_pickware_not_relevant_for_picking": false
  },
  "productNumber": "71958",
  "active": true,
  "createdAt": "2022-09-12",
  "isCloseout": false,
  "markAsTopseller": false,
  "allowNotification": false,
  "manufacturerNumber": "6ES7390-1AF30-0AA0",
  "stock": 1,
  "minStock": 0,
  "position": 0,
  "weight": 0.65,
  "minPurchase": 1,
  "shippingFree": false,
  "purchasePrices": [
    {
      "currencyId": "b7d2554b0ce847cd82f3ac9bd1c0dfca",
      "gross": 11.0,
      "net": 11.0,
      "linked": true
    }
  ],
  "purchaseSteps": 1,
  "restockTime": 1,
  "categories": [
    { "id": "ce4792fce0c94e2b9351bfd10294cdf8" },
    { "id": "d58dc222a2b94ff9b5b1435173a1c699" }
  ],
  "visibilities": [
    {
      "id": "28aae3cb7b4744ef962440cfd96d765f",
      "productId": "b4a75f0115184675bdade12c1e461a18",
      "salesChannelId": "df1c836c5543413bad290b171cc6ffe6",
      "visibility": 30
    },
    {
      "id": "ca5c0a31bd964dcb802ebb1af4891cdf",
      "productId": "b4a75f0115184675bdade12c1e461a18",
      "salesChannelId": "0fb0904d67ae4175b244798e0e36581f",
      "visibility": 30
    }
  ]
}

Wir haben das Problem für uns gelöst. Wir haben nach der ersten Migration nicht mehr benötigte Verkaufskanäle gelöscht. Bei den Produkten aus dem alten Shop wurde aber in der Tabelle swag_migration_data im Feld converted auf diesen Verkaufskanal referenziert - siehe Beispiel oben (salesChannId = df1c836c5543413bad290b171cc6ffe6).

Als Lösung haben wir einen neuen (nicht aktiven) Verkaufskanal angelegt und über das Tool Adminer die ID des neuen Verkaufskanales auf „df1c836c5543413bad290b171cc6ffe6“ geändert.

Danach ist die Migration wieder durchgelaufen. Also Vorsicht beim Löschen von Verkaufskanälen, sollte wirklich erst nach dem kompletten Abschluss der Migration erfolgen!