OroCommerce Forums

Covering OroCommerce topics, including community updates and company announcements.

Forums Forums OroCommerce 3.1.9: Add a custom choice filter to frontend-product-search-grid

This topic contains 4 replies, has 2 voices, and was last updated by  Frank 7 months, 2 weeks ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
  • #40233


    Hi there,

    I fail in adding a custom choice filter, like ‘brand-filter’ to frontend-product-dearch-grid:

    First a tried to add a new filter type choice to datagrids.frontend-product-search-grid.filters-node:

    The exception message is something like ‘no type choice allowed’.

    I tried to find, how brand-choice-filter was added in oro-core bundles. It is definitely not set as params in datagrids.yml, but in some higher layer …?
    The only hint I have got is, that oro/platform/…/FilterBundle/Filter/ChoiceFilter.php has to be used.
    But how to integrate it into frontemd-datagrid, I could nor find out.

    Need help.

    Thanks a lot.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Author
  • #40242
    Andrey Yatsenko
    Andrey Yatsenko

    Your filter definition looks ok but it’s incomplete.

    To add a new filter it is also required to add a field to the source.query first and as you are extending the “frontend-product-search-grid” grid, you should note that for performance reasons it is different from regular grids as it uses source.type = search instead of orm so the search index is used and to query the field, first you should add this field to the website search index, see https://oroinc.com/b2b-ecommerce/doc/current/architecture/tech-stack/search-index

    Also, as the number of users in a system can be big it’s actually recommended to use autocomplete filter instead of choice.

    As an example of autocomplete filter, you can use the owner filter at the dashboards grid, see attached screenshot.

    The filter definition can be found here https://github.com/oroinc/platform/blob/master/src/Oro/Bundle/DashboardBundle/Resources/config/oro/datagrids.yml#L49-L55.
    You probably will also have to create a custom autocomplete search handler, here is the definition of the one for the above example: https://github.com/oroinc/platform/blob/master/src/Oro/Bundle/UserBundle/Resources/config/services.yml#L236-L246

    1. Screen-Shot-2019-08-20-at-1.23.43-PM-128x72


    Hi Andrey,

    your recommandations sound very helpful! I will try to build an frontend-autocomplete-filter, and report here about the results.
    Thank you for your efforts.

    Kind regards



    Hi Andrey,

    thanks for recommendations.

    Unfortunately it DOES NOT work. Before trying a custom autocomplete search handler, I used the business-units-tree-search-handler provided by oro in two alternative scenarios:


    It results in the error-message:

    An exception has been thrown during the rendering of a template (“Invalid configuration for path “filters.columns.businessUnitId.type”: Invalid filter type “”Choice-tree”””) in “OroProductBundle:layouts/blank/imports/oro_datagrid_server_render:server_render_datagrid.html.twig”.

    Like https://github.com/oroinc/platform/blob/master/src/Oro/Bundle/DashboardBundle/Resources/config/oro/datagrids.yml#L56-L69.


    An exception has been thrown during the rendering of a template (“Invalid configuration for path “filters.columns.businessUnitId.type”: Invalid filter type “”choice-business-unit”””) in “OroProductBundle:layouts/blank/imports/oro_datagrid_server_render:server_render_datagrid.html.twig”.

    It seems, filter-types ‘choice-tree’, and ‘choice-business-unit’ are NOT REGISTERED FOR FRONTEND. Can you help me, how to do that?




    Hi Oro-Team,

    my custom-filter topic is still unresolved. Could you be so kind, and have a look at my last post?

    Thanks a lot.

Viewing 4 replies - 1 through 4 (of 4 total)

The forum ‘OroCommerce’ is closed to new topics and replies.

You will be redirected to [title]. Would you like to continue?

Yes No