You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

从Shopware5迁移至Shopware6时日志出现SWAG_MIGRATION_RUN_EXCEPTION异常求助

Shopware 5.7 迁移至 6.4.13 数据未显示且类型错误问题

环境信息

  • PHP版本:8.1
  • Shopware版本:6.4.13
  • 迁移场景:Shopware 5.7(带演示数据)→ Shopware 6.4.13(本地虚拟环境)
  • 操作:已按官方迁移流程执行,使用本地网关配置

问题现象

迁移状态显示“成功”,但Shopware 6后台及前端无迁移数据,迁移日志存在类型不兼容错误:

[error] SWAG_MIGRATION_RUN_EXCEPTION
An exception occurred
Entity: language, sourceId: -
SwagMigrationAssistant\Migration\Logging\Log\ExceptionRunLog::__construct(): Argument #4 ($sourceId) must be of type ?string, int given, called in /var/www/webdev/shopware56/custom/plugins/SwagMigrationAssistant/Migration/Service/MigrationDataConverter.php on line 144

[error] SWAG_MIGRATION_RUN_EXCEPTION
An exception occurred
Entity: category, sourceId: -
SwagMigrationAssistant\Profile\Shopware\Converter\ShopwareConverter::getSourceIdentifier(): Return value must be of type string, int returned

[error] SWAG_MIGRATION_RUN_EXCEPTION
An exception occurred
Entity: customer_group, sourceId: -
SwagMigrationAssistant\Profile\Shopware\Converter\ShopwareConverter::getSourceIdentifier(): Return value must be of type string, int returned

[error] SWAG_MIGRATION_RUN_EXCEPTION
An exception occurred
Entity: sales_channel, sourceId: -
SwagMigrationAssistant\Profile\Shopware\Converter\ShopwareConverter::getSourceIdentifier(): Return value must be of type string, int returned

解决方案

1. 匹配迁移助手插件版本

Shopware 6.4.13 与高版本SwagMigrationAssistant存在PHP 8.1类型兼容性问题,需安装与Shopware 6.4.x严格匹配的插件版本(推荐SwagMigrationAssistant 3.4.x系列,对应Shopware minor版本号)。

2. 临时修复类型转换问题(仅调试用,优先升级插件)

  • 修改/var/www/webdev/shopware56/custom/plugins/SwagMigrationAssistant/Migration/Service/MigrationDataConverter.php第144行,将$sourceId强制转为字符串:
    // 原代码
    $log = new ExceptionRunLog($runId, $entity, $sourceId, $exception);
    // 修改后
    $log = new ExceptionRunLog($runId, $entity, (string)$sourceId, $exception);
    
  • 修改SwagMigrationAssistant/Profile/Shopware/Converter/ShopwareConverter.php的getSourceIdentifier方法,确保返回字符串类型:
    public function getSourceIdentifier(): string
    {
        return (string)$this->source['id'];
    }
    

3. 重置迁移流程

  • 在Shopware 6后台删除当前迁移任务,清空迁移日志
  • 重新创建迁移连接,执行全量迁移
  • 迁移完成后清除缓存:
    bin/console cache:clear
    bin/console cache:warmup
    

4. 检查源数据ID格式

确认Shopware 5中language、category等实体的ID为标准整数类型,避免自定义场景下的非标准ID导致转换失败。

内容的提问来源于stack exchange,提问作者Softound Solutions

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.24 14:15:41