Search code examples
shopwareshopware6shopware6-app

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


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


Solution

  • 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"
            }
        ]
    }