How to make product properties aggregations in Shopware 6 app script?

257 Views Asked by At

I would like to make a criteria in an app script to get the aggregated properties for products (ManyToManyAssociationField "properties").
I already know hot to get the aggregations for a ManyToOneAssociationField like "manufacturer"

{
        "associations": {
            "manufacturer": {},
        },
        "aggregations": [
            {
                "name": "manufacturer",
                "type": "entity",
                "definition": "product_manufacturer",
                "field": "manufacturerId"
            }
        ]
    }

but i don't understand how to do it for a ManyToManyAssociationField

1

There are 1 best solutions below

0
On BEST ANSWER

Just use the dot notation to refer to the id field of the referenced definition.

{
    "aggregations": [
        {
            "name": "properties",
            "type": "entity",
            "definition": "property_group_option",
            "field": "properties.id"
        }
    ]
}