I want to populate sub objects from order object like deliveries, addresses, paymentMethod, etc. - but how? Query Body of POST against {{shop_url}}/api/search/order
"ids": ["xxx"],
"includes": {
"order": ["id", "orderNumber", "createdAt", "lineItems", "orderCustomer", "currency", "language", "salesChannel", "addresses", "billingAddress", "meta", "shippingCosts", "deliveries" ],
"order_line_item": ["label", "position", "quantity", "unitPrice", "productId", "product", "price"],
"product": ["ean"]
},
"associations": {
"lineItems": {
"associations": {
"product": []
}
}
}
}
I get following response:
"deliveries": {
"data": [],
"links": {
"related": "https://xxx/api/order/<id>/deliveries"
}
},
Is there a way to get data from provided link in my first response? How?
You have to add the objects you want to populate to the associations
and includes
just like you did with the lineItems
. Use for example this request to get deliveries, addresses and payment method:
{
"ids": ["xxx"],
"includes": {
"order": ["id", "orderNumber", "createdAt", "lineItems", "orderCustomer", "currency", "language", "salesChannel", "addresses", "billingAddress", "meta", "shippingCosts", "deliveries", "transactions" ],
"order_line_item": ["label", "position", "quantity", "unitPrice", "productId", "product", "price"],
"product": ["ean"]
},
"associations": {
"lineItems": {
"associations": {
"product": {}
}
},
"deliveries": {},
"addresses": {},
"transactions": {
"associations": {
"paymentMethod": {}
}
}
}
}
Then you will find those objects in the response in included
:
{
"data": [
{
"id": "59eb05bcc72e4c8fb85634dfce27d9ff",
"type": "order",
"attributes": {
"orderNumber": "10052",
"shippingCosts": {
"unitPrice": 0.0,
"quantity": 1,
"totalPrice": 0.0,
"calculatedTaxes": [
{
"tax": 0.0,
"taxRate": 25.0,
"price": 0.0,
"extensions": []
}
],
"taxRules": [
{
"taxRate": 25.0,
"percentage": 100.0,
"extensions": []
}
],
"referencePrice": null,
"listPrice": null,
"extensions": []
},
"createdAt": "2022-05-16T15:22:25.405+00:00",
"apiAlias": null
},
...
}
],
"included": [
{
"id": "2ab1012505fe4e1ab8cc74ff617fd65a",
"type": "order_address",
"attributes": {
"versionId": "0fa91ce3e96a4bc2be4bd9ce752c3425",
"countryId": "5e9a60f273904621896f7ff6bff2a476",
"countryStateId": null,
"orderId": "59eb05bcc72e4c8fb85634dfce27d9ff",
"orderVersionId": "0fa91ce3e96a4bc2be4bd9ce752c3425",
"salutationId": "655d4bb9865d407692858b4edb540593",
"firstName": "xxx",
"lastName": "xxx",
"street": "xxx",
"zipcode": "xxx",
"city": "xxx",
"company": null,
"department": null,
"title": null,
"vatId": null,
"phoneNumber": "xxx",
"additionalAddressLine1": null,
"additionalAddressLine2": null,
"customFields": null,
"createdAt": "2022-05-16T15:22:25.396+00:00",
"updatedAt": null,
"apiAlias": null
},
...
},
{
"id": "6a294fe46d344bbd9c7cbbef33691544",
"type": "order_delivery",
"attributes": {
"versionId": "0fa91ce3e96a4bc2be4bd9ce752c3425",
"orderId": "59eb05bcc72e4c8fb85634dfce27d9ff",
"orderVersionId": "0fa91ce3e96a4bc2be4bd9ce752c3425",
"shippingOrderAddressId": "2ab1012505fe4e1ab8cc74ff617fd65a",
"shippingOrderAddressVersionId": "0fa91ce3e96a4bc2be4bd9ce752c3425",
"shippingMethodId": "d9befc806b1d40b5ac4eb6d7d93e1c85",
"stateId": "1481b0eaffeb43a7b35e4e7f92b8d26b",
"trackingCodes": [],
"shippingDateEarliest": "2022-05-17T00:00:00.000+00:00",
"shippingDateLatest": "2022-05-19T00:00:00.000+00:00",
"shippingCosts": {
"unitPrice": 0.0,
"quantity": 1,
"totalPrice": 0.0,
"calculatedTaxes": [
{
"tax": 0.0,
"taxRate": 25.0,
"price": 0.0,
"extensions": []
}
],
"taxRules": [
{
"taxRate": 25.0,
"percentage": 100.0,
"extensions": []
}
],
"referencePrice": null,
"listPrice": null,
"extensions": []
},
"createdAt": "2022-05-16T15:22:25.399+00:00",
"updatedAt": "2022-05-16T15:22:25.613+00:00",
"apiAlias": null
},
...
},
{
"id": "e45170b5221344dc8aa49bd723eaa281",
"type": "product",
"attributes": {
"ean": null,
"apiAlias": null
},
"links": {
"self": "http://localhost/api/product/e45170b5221344dc8aa49bd723eaa281"
},
"relationships": [],
"meta": null
},
{
"id": "eb8be118861546abbdfb1b9d28079ddc",
"type": "payment_method",
"attributes": {
"pluginId": null,
"name": "Credit card",
"distinguishableName": "Credit card",
"description": "",
"position": 2,
"active": true,
"afterOrderEnabled": false,
"customFields": null,
"availabilityRuleId": null,
"mediaId": null,
"formattedHandlerIdentifier": "handler_shopware_defaultpayment",
"createdAt": "2022-03-25T11:02:55.896+00:00",
"updatedAt": "2022-03-25T11:49:09.886+00:00",
"translated": {
"name": "Credit card",
"distinguishableName": "Credit card",
"description": "",
"customFields": []
},
"apiAlias": null
},
...
},
...
],
"links": {
"self": "http://localhost/api/search/order"
},
"meta": {
"totalCountMode": 0,
"total": 1
},
"aggregations": []
}