Jump to content

Filters in prestashop not working


dtgmaze

Recommended Posts

Hi, 

 

Filters are not working correctly.

 

When I filter on Brand it's not working correct

http://www.loveforrain.nl/26-regenjas#/merken-rains

try the link >> this filter does not work (brand)

 

when I filter on everything else no problem.

http://www.loveforrain.nl/26-regenjas#/kleur-geel

try the link >> this filter works

 

this is very anoying when users make a filter selection, and then go back to category view.

Then they loose the Filtered options.

 

Grtz, 

Dennis

  • Like 1
Link to comment
Share on other sites

It's a core bug. It's not supposed to recognize anything apart from "manufacturer" in the code.
So what you need to do is find the piece of broken code and add a condition like if the name is merken, it will rename it manufacturer for that bit of code.
Sadly, I can't recall the right spot off the top of my head, but it's in blocklayered.php, somewhere around getFilteredProducts

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 year later...

Dont know if you still need help, open blocklayered.php.

Find line around line 1729:

 $selected_filters[$attribute_name] = array($this->filterVar($url_parameters[0]), $this->filterVar($url_parameters[1]));

Add after this line another else if:

     else if ($attribute_name == 'merk') {
                        $merk = str_replace("_", " ", $url_parameters[0]);
                        $merk2 = str_replace("_", "-", $url_parameters[0]);
                        $manufacturers = Db::getInstance()->executeS('select id_manufacturer from ps_manufacturer where name = "'.$merk.'"');
                        if(!empty($manufacturers)) {
                            $selected_filters['manufacturer'] = array($manufacturers[0]['id_manufacturer']);
                        } else {
                            $manufacturers = Db::getInstance()->executeS('select id_manufacturer from ps_manufacturer where name = "'.$merk2.'"');
                            if(!empty($manufacturers)) {
                                $selected_filters['manufacturer'] = array($manufacturers[0]['id_manufacturer']);
                            }
                        }
                    }

NOTE: replace "merk" in my code with "merken" for your code to work.

 

Now it should work! :)

Edited by DutchPresta (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...