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
相关产品推荐
相关产品推荐

