E
E
Evgeniy Samoilenko2014-06-22 20:52:20
PHP
Evgeniy Samoilenko, 2014-06-22 20:52:20

How to create filter products in opencart?

Situation:
I'm putting together an online store on opencart, I did almost everything necessary, there were no special problems.
But still there was one plug - filtering goods. You need to filter by manufacturer, by color, by price (price range). I can roughly imagine what I need to do:
1) Display a list of all manufacturers (available)
2) display a list of all possible colors (not done)
3) Make a slider with a choice of price range (done, but the maximum and minimum prices of goods are not taken into account)
4 ) When applying a specific filter, it should add variables and values ​​​​with a get request, which then should be used in the controller, and then in the model. Here is the main problem with this:
I don’t understand how the selection itself takes place, where to add the handlers of these same get-requests.
Here is a list of questions that I would like to get answers to, if possible:
1) How to process get-requests correctly (as I understand it, they need to be "caught" in the category module)?
2) Where is there a detailed description of how models work in opencart? Preferably specific links, you can lessons, you can in English. language
3) How to correctly implement a filter by product colors? Can this be done with standard opencart tools ??

Answer the question

In order to leave comments, you need to log in

5 answer(s)
P
Par Mactep, 2014-06-23
@samoilenkoevgeniy

1. get-requests are "caught" through the class methods of the corresponding controller. Sounds a little messy. I'll try to explain with an example.
The /index.php?route=product/category&path=20 request calls the index method of the ControllerProductCategory class in the /catalog/controller/product/category.php file. Query
parameters are placed in the request property of this controller
2. OpenCart documentation
Very poor. I heard that there is a more detailed one, but it costs $25 and there is no insight after reading)
OpenCart developers believe that their code is absolutely intuitive and does not need explanation)
3. Approximately:
You need to make a url like /index.php?route=product/filter&manufacturer&lowprice=20&hiprice=100&color=red (or a little differently if you have a CNC)
Process it in the /catalog/controller/product/filter.php file
There are some standard filters. You just have to add yours.

J
Jenovas, 2014-06-23
@jenovas

Isn't it easier and faster to use the filter pro module?

H
halfhope, 2014-12-21
@halfhope

FilterPro, OCFilter

D
Dmitry, 2016-03-29
@sonics

there is also a cool MegoFilterPro, unlike FilterPro, it is available under OC 2

D
DimaOC, 2017-10-19
@DimaOC

Product filter:
for Opencart 2.x https://opencart2x.ru/moduli/vid/umniy-filtr-tovarov
for Opencart 3.x https://opencart3x.ru/module/front/product-filter

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question