Shopware 6 add entity extension fields to admin search

Viewed 157

I wonder how to make some fields of an entity extension searchable in the administration through the "/api/search/my-entity" api-endpoint. By default they are not considered during search as it looks like.

2 Answers

I found the answer by debugging the search-endpoint:
The association-Field of the EntityExtension needs to have a SearchRanking-flag:

...->addFlags(new SearchRanking(SearchRanking::ASSOCIATION_SEARCH_RANKING))

Then you can add SearchRanking-flags in the EntityExtensionDefinition as you like, e.g.:

(new StringField('test', 'test'))->addFlags(new SearchRanking(SearchRanking::HIGH_SEARCH_RANKING)),

After that the fields are searchable via the search-endpoint :)

Related