Search code examples
symfonyakeneo

Akeneo API - Getting children product models


I'm on Akeneo 2.3 & have a product structure as

Product Model (Master) -> Product Model (Color) -> Product (Size)

I'm trying to call this endpoint

{{url}}/api/rest/v1/product-models?search={
    "parent": [{
        "operator": "=",
        "value": "DRZ9186"
    }]
}

However, I'm getting

{
    "code": 422,
    "message": "Filter on property \"parent\" is not supported or does not support operator \"=\""
}

Now I'm not quite sure whether parent is genuinely not supported via the filter as they are not mentioned here https://api.akeneo.com/documentation/filter.html

Pretty sure it comes down to \Pim\Bundle\ApiBundle\Checker\QueryParametersChecker::checkPropertyParameters but that's where I couldn't move further.


Solution

  • The "parent" property is not available right now on the Akeneo Web API.

    You are right about QueryParametersChecker::checkPropertyParameters. It checks which properties can be used based on its service definition. As you can see, parent is not one of the authorized fields.

    By the way, even if it was available, there is currently no operator = for the property parent. Available operators are IN, EMPTY and NOT EMPTY. So instead of:

    search={"parent":[{"operator":"=","value":"DRZ9186"}]
    

    the correct request would be:

    search={"parent":[{"operator":"IN","value":"[DRZ9186]"}]
    

    Don't hesitate to open a feature request on Akeneo GitHub repository, describing your use case. Akeneo product owners will certainly be interested.