OroCommerce Forums

Covering OroCommerce topics, including community updates and company announcements.

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

This topic contains 3 replies, has 2 voices, and was last updated by  Frank 5 days, 22 hours ago.

  • Creator
    Topic
  • #40233

    Frank
    Participant

    Hi there,

    I fail in adding a custom choice filter, like ‘brand-filter’ to frontend-product-dearch-grid:
    https://snipboard.io/AaRTXD.jpg

    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.
    Frank

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
    Replies
  • #40242
    Andrey Yatsenko
    Andrey Yatsenko
    Moderator

    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

    Attachments:
    #40244

    Frank
    Participant

    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
    Frank

    #40436

    Frank
    Participant

    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:

    1)

    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”.

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

    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-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?

    Thanks
    Frank

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

You must be logged in to reply to this topic.

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

Yes No