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

Shopware 6 Sync API推送产品:能否通过shortName自动匹配unitId?

Shopware 6 Sync API 产品单位匹配问题

Shopware 6的Sync API支持通过唯一标识字段自动关联实体,不用硬传unitId,但你之前的格式没写对。

正确的写法是通过identifier指定用shortCode来匹配已有单位:

"unit": {
    "shortCode": "kg",
    "identifier": "shortCode"
}

注意shortCode是单位实体的基础字段,不是翻译字段,所以不用嵌套在translations里,你之前的两种写法都没加identifier,所以API识别不出来。

如果系统里还没有对应shortCode的单位,想让API自动创建的话,加上autoCreate: true,同时补充必要的字段(比如多语言名称):

"unit": {
    "shortCode": "kg",
    "identifier": "shortCode",
    "autoCreate": true,
    "translations": {
        "en-GB": {
            "name": "Kilogram"
        }
    }
}

另外要确认你的Shopware版本在v6.3及以上,这个功能是从该版本开始支持的。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.12 08:12:01