Shopware 6 API:更新没有库存或价格的现有产品

Shopware 6 API: Update an existing product without stock or price

商店中产品的库存条目由与更新产品信息(编号、属性等)的系统不同的 ERP 系统更新是很常见的。 Shopware 6 似乎不支持此方法并抛出如下所示的错误。

我确实了解,对于产品的初始创建,有一些必填字段,例如 productNumberstock 但是在更新 一个已经存在的产品,完全可以忽略这些值,这样它们就可以由外部系统更新。

这在 Shopware 5 中有效,但在 Shopware 6 中无效。有人知道解决方法吗?

(我正在考虑从 Shopware 发送现有值,因为它在技术上 未更新 但这是我最后的选择。)

Array
(
    [code] => c1051bb4-d103-4f74-8988-acbcafc7fdc3
    [status] => 400
    [detail] => This value should not be blank.
    [template] => This value should not be blank.
    [meta] => Array
        (
            [parameters] => Array
                (
                    [{{ value }}] => null
                )

        )

    [source] => Array
        (
            [pointer] => /0/stock
        )

)

请求负载的完整示例

{
    "newData": {
        "action": "upsert",
        "entity": "product",
        "payload": [
            {
                "id": "206c59a3339383101655aae7598e328c",
                "language": "default",
                "taxId": "6460303d84264f36858d1fe9e8c2f60f",
                "name": "SLT 95 Nano Crystal",
                "active": true,
                "visibilities": [
                    {
                        "id": "d43840cff1b2bcc741a9a83ebb5b3c16",
                        "salesChannelId": "e8d8fd2337dd42e0a86b47ea68739824",
                        "visibility": 30
                    }
                ],
                "categories": [
                    {
                        "id": "66ca2d80dc532d4d6659b4430e6954a8"
                    }
                ],
                "description": "A not so much very short text. Another short text.",
                "price": [
                    {
                        "net": 9999.99,
                        "gross": 9999.99,
                        "linked": true,
                        "currencyId": "b7d2554b0ce847cd82f3ac9bd1c0dfca"
                    }
                ],
                "productNumber": "P_10254",
                "crossSellings": [
                    {
                        "id": "b3e3171397d30794171877fed2329d96",
                        "name": "Similar Products",
                        "assignedProducts": [],
                        "type": "productList",
                        "active": true,
                        "sortBy": "name",
                        "sortDirection": "ASC",
                        "limit": 24,
                        "position": 1
                    }
                ]
            }
        ]
    }
}

请求负载的简短示例

        "payload": [
            {
                "id": "206c59a3339383101655aae7598e328c",
                "language": "default",
                "taxId": "6460303d84264f36858d1fe9e8c2f60f",
                "name": "SLT 95 Nano Crystal",
                "active": true,
                ...
            }
        ]

我只是不发送正常产品更新的库存,希望 Shopware 使用现有库存。

在“v6.4.4.1 稳定版”版本中,Shopware 引入了概念更改,允许您更新现有产品,而无需发送所有必填字段。

这解决了这个问题并且非常有用,例如,如果库存应该由手动维护而不是由 API 调用控制。