Search code examples
phpshopwareshopware6shopware6-api

How to fetch orders from past x hours via Shopware Admin API?


The POST request to the https://shop-URL/api/search/order endpoint requires a filter in order to return a specific selection.

I can't any examples or proper documentation about what the payload would have to look like in order to be able to fetch orders in between certain dates.


Solution

  • This is possible with a filter. The filter has to look like this:

    {
      "type": "range",
      "field": "createdAt",
      "parameters": {
        "lte": "2021-01-17T12: 00: 00.333+00: 00"
      }
    }
    

    Of course this is only an example and needs adjustment or multiple range filters to deliver the right result.