Instead of trying to find the parent of one variant, you could try searching for products where a child has the ID "xyz". Shopware supports filtering for nested objects like "children.id".
For example:
POST /store-api/product
Content-Type: application/json
Accept: application/json
sw-access-key: ...
sw-language-id: ...
{
"includes": {
"product": ["productNumber", "children", "name", "translated.name"]
},
"associations": {
"children": []
},
"filter": [
{"field": "children.id", "type": "equals", "value": "f87a875bc5fa47e08ea40a19ce9c5627"}
]
}
Should give you parent and children output:
{
"entity": "product",
"total": 1,
"aggregations": [],
"page": 1,
"limit": null,
"elements": [
{
"productNumber": "252009 00-0002",
"name": null,
"children": [
{
"productNumber": "252009 00-0002.3",
"name": null,
"children": null,
"translated": {
"name": "T-Shirt Logo"
},
"apiAlias": "product"
},
{
"productNumber": "252009 00-0002.1",
"name": null,
"children": null,
"translated": {
"name": "T-Shirt Logo"
},
"apiAlias": "product"
},
{
"productNumber": "252009 00-0002.4",
"name": null,
"children": null,
"translated": {
"name": "T-Shirt Logo"
},
"apiAlias": "product"
},
{
"productNumber": "252009 00-0002.2",
"name": null,
"children": null,
"translated": {
"name": "T-Shirt Logo"
},
"apiAlias": "product"
}
],
"translated": {
"name": "T-Shirt Logo"
},
"apiAlias": "product"
}
],
"apiAlias": "dal_entity_search_result"
}