Locastic / ApiPlatformTranslationBundle

Translation bundle for ApiPlatform based on Sylius translation
MIT License
84 stars 27 forks source link

Filters on translated fields #24

Closed akira28 closed 4 years ago

akira28 commented 4 years ago

Seems that SearchFilter doesn't work out of the box. Do you have any suggestion on how to make it work? Ideally it should be as easy as this:

/products?locale=es&name=foo

where name is a translated field.

CoalaJoe commented 4 years ago

In the filter, add the property translations.name and use that in the request /products?locale=es&translations.name=foo.

The SearchFilter is an ORM Filter (Being executed on the Database). Therefore the property name would not be available on that table. Specifying translations.name indicates that the field to do the search in, is in the translations relation.

akira28 commented 4 years ago

Thanks! It would be cool if there was no need to add the translations. prefix, but is not a blocker :)