2
1 Comment

E-Commerce filters - how did you implement them?

I'm actually wondering how you implemented filters on e-commerce in your software.

From frontend-to-backend.

What were your considerations to implement it like that?
With what did you have trouble?

on June 13, 2020
  1. 1

    Frontend:

    • A simple form on a get Url
      Every changed checkbox results into a form submit

    • Selected filters are shown in the top of the filter list.

    Backend:

    • Implemented the specification pattern so i could easily use a combined filter ( or and and specifications).

    If a filter belongs to the same "category", an Or operator is performed on the different values.
    Eg. filter => (BeerStyle = IPA or Brown )

    If a filter belongs to another category, the specifications ( eg. in or) are created.
    Eg. (BeerStyle = IPA or Brown ) AND ( Price = Between(6.5,10.50) )

    With the specification pattern, the combined filter is transformed to an expression and then transformed to a SQL query.

    No angular or other things. Only a submit when a filter is changed. The list is immediatly shown.

    There is some translation logic in between the frontend and backend to transform the url parameters to the appropriate search model.

    End result: Performance is between 200ms-600 ms for returning the page. I'm still thinking about ways to improve it.

    Testable on http://test.belgianbrewed.com/?filter=1&AttributeCandidateIds=99a62c80-5921-e911-967f-8e789af484ec

    Note: currently only breweries is implemented. But you can manually add &PriceBetween=(3-10) for example as a parameter