SW6 Api api/search/order wie die Ausgabe von Feldern einschänken (avatar, alias, id's, etc.)?

Hi,
die API für SW6 ist ja herrlich heftig.
Ich versuche eine Ausgabe der Bestellungen mit den Feldern id, orderNumber, createdAt, email, produkt name, anzahl… mit:

{
"associations": { "lineItems": {}, "billingAddress": {}, "createdBy": {} },
"includes": { "order": [ "id", "orderNumber", "createdAt", "lineItems", "createdBy" ],
"order_line_item": [ "label", "quantity"],
"order_createdBy": [ "email" ]
}
}

ergibt:

{"total":1,"data":[{"orderNumber":"10000","lineItems":[{"quantity":1,"label":"Main product","apiAlias":"order_line_item"}],"createdBy":{"localeId":"f2b5abbdb3c349eea6359b5aa3278269","avatarId":null,"username":"admin","firstName":"","lastName":"admin","title":null,"email":"info@shopware.com","active":true,"admin":true,"aclRoles":null,"locale":null,"avatarMedia":null,"media":null,"accessKeys":null,"configs":null,"stateMachineHistoryEntries":null,"importExportLogEntries":null,"recoveryUser":null,"lastUpdatedPasswordAt":null,"createdOrders":null,"updatedOrders":null,"timeZone":"UTC","_uniqueIdentifier":"bb23bff6e8784055bffe933a23954efa","versionId":null,"translated":[],"createdAt":"2021-10-14T13:04:03.221+00:00","updatedAt":null,"extensions":{"foreignKeys":{"apiAlias":null,"extensions":[]},"internal_mapping_storage":{"apiAlias":null,"extensions":[]}},"id":"bb23bff6e8784055bffe933a23954efa","customFields":null,"apiAlias":"user"},"createdAt":"2022-06-07T13:35:08.559+00:00","id":"9b75ff3d36384196be532ac104c129f0","apiAlias":"order"}],"aggregations":[]}

Bei /apt/orders klappte nicht mal eine Limitierung der Felder (laut doku „includes“?), Parameter ignorierte er dort völlig.

Unter /api/search/order
gibt er mir u.a. allen möglichen Overhead von createdBy aus, dabei soll er davon nur die email ausgeben.

Kann mir jemand erklären, was ich da falsch mache?

ich meinte natürlich so … sorry :slight_smile:

{
"associations": { "lineItems": {}, "createdBy": {} },
"includes": { "order": [ "id", "orderNumber", "createdAt", "lineItems", "createdBy" ],
              "order_line_item": [ "label", "quantity", "unitPrice", "totalPrice" ],
              "user": [ "username", "firstName", "lastName", "email" ]
            }
}
1 Like

Ja, das ist deutlich besser, als was ich hatte.
Danke Dir!