Search code examples
shopware

Shopware 6 send multiple objects over one API Call


I wrote a script that updates one product after another in my Shopware 6 system using its API. (Each product is updated with a separate API call.)

This is super slow and not really performant, so I tried to send multiple products as a collection using one call. Sadly this doesn't seem to work with Shopware 6.

Does anyone know if and how to send multiple product objects using one API call only?

What I currently have, roughly looks like this:

$product = [
    "id" = 1, "someData" = "someData"
];
callApi($products);
$product = [
    "id" = 2, "someData" = "someData2"
];
callApi($products);
$product = [
    "id" = 3, "someData" = "someData3"
];
callApi($products);

From some experience with other systems you can mostly create a multi-object like this:

$products = [
    ["id" = 1, "someData" = "someData"],
    ["id" = 2, "someData" = "someData2"],
    ["id" = 3, "someData" = "someData3"]
]
callApi($products);

Solution

  • For use cases like this a special /sync endpoint exist that may be used for bulk operations.

    Please refer to the official api documentation.