Post by xtensions » Tue Mar 15, 2016 9:55 am

Hi

I need an advice on building a filter solution. The project has more than about 1000 products in each category. And each category will have filter system based on brand, and attributes. One of the categories have 170 attributes linked to the products within that category. All of this attributes will be displayed on product page and comparison page. We have already built that solution. Coming back to filters page, we need to provide user with a filter functionality on category/filter page, where user can filter 1000 products on the basis of Manufacturer, and 20 attributes.

With each attribute we will put unique product_attribute value stored in system. For example size filter on a clothing site, will display all unique sizes that are available in the products within that category. So it will be like 20 size like filters. Coming to performance of the system when the site is accessed by large number of users, I am trying to figure out what would be an ideal solution to build this functionality.

Basic requirement:
No reload of page, Ajax based filter with content changing as filters are applied or removed.

Possible Solutions

1. Use a filter module from extension market, which generally work on the lines when each filter is changed, ajax events communicates with server and server runs a query in db and fetches the data with way too many WHERE clause and JOINS. And then does the operations on it in controller and sends back as json, and then javascript will change the content. Performance wise, It is reasonable as long as 5-6 filters are applied, but supposing if 10-15 filters are applied by user, the query will take a lot of time to retrieve and render the content. Each filter could have one or more values applied, like a user want to see sizes XL OR L and with colors White Or Red Or Blue. So within one attribute we are asking query to check WHERE COLOR IS WHITE OR BLUE OR RED AND SIZE is XL OR L. And 20 of them atrributes could do that.

2. Instead of using filters through query retrieval, we store all products and filter data in a file as json object or array format (file cache). Which updates itself once a day with fresh data or when a new product is added, updated or removed in admin. So when a filter is applied same ajax request should not query the db with WHERE and Joins but instead use raw products data stored in json file and applies the operation in php code with if and elses as per the filter set. Do you think it will have any better impact on the performance. As we will have reduced the interaction between code and database on each filter request, resulting in faster execution and rendering of data.

3. Client side filtering: See these
http://jiren.github.io/filter.js/pagination.html
http://jiren.github.io/filter.js/index.html

These are the solutions that filter products on client side. Making it the most performance rich solution.
Link: https://github.com/jiren/filter.js/tree/master
They send the json object in javascript file when the page is loaded for the first time. File: http://jiren.github.io/filter.js/data/movies.js
And when a filter is applied the same event will not call server for an output but instead it will do filter using javascript code on json data that is stored in the browser. This json data can also be cached on client site, unless we push it to refresh. This will ensure zero communication with server to run filter queries.

Let me know what do you think would possibly be a faster and recommended solution and why. Or if you could think of a better solution for my requirement.

Thanks

Newbie

Posts

Joined
Fri Sep 13, 2013 11:16 pm

Post by artcore » Thu Mar 17, 2016 5:56 am

Hi,

IMHO #2 has the advantage of having the search params in the url making it easy for the customer to revisit the filtered results.
And with the main data cached (file or memory) the server strain is minimal. Ajax is doing the work here as well as in #3
I'm not sure if filterjs also has the ability to add query params but shouldn't be too hard to add.

I must say I like client side too but as a third party tool you are relying on the autor to maintain it. Plus the source code is harder to understand compared to php/sql (at least for me ;D ) If you need custom additions you better be a js master.

But the client side filter simplicity is tantalizing.

Hope that helps,
Cheers

Attn: I no longer provide OpenCart extensions, nor future support - this includes forum posts.
Reason: OpenCart version 3+ ;D

Thanks!


User avatar
Active Member

Posts

Joined
Tue Jul 09, 2013 4:13 am
Location - The Netherlands
Who is online

Users browsing this forum: No registered users and 24 guests