Jump to content

Layered Navigation price slider don't work with price range


jorge911

Recommended Posts

Hi,

 

I want to use a URL to go to a page where the layered navigation price slider filter is used.

 

In other words, I want to list all products within a price range when clicking on a link like this:

 

index.php?id_category=3&controller=category#/price-2-25

 

The issue is that I have no product with a price of 25€ (not exactly 25€ and neither a rounded 25€). So when I go to a link like this the layered navigation shows all prices.

 

On the other hand if I have a product for 27€ and I use a link link:

index.php?id_category=3&controller=category#/price-2-27

 

It does work correctly.

 

Could someone point me to where in blocklayered.php or other file I need to modify so it behavies as desired. I cannot be the only one that wants the price slider to be a little more flexible on the price ranges....

 

I'm on version 1.6.0.14 and with the blocklayered module fully updated.

 

Thanks.

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

I'm answering myself for the benefit of others that might have the same issue as I have solved it.

 

It is an issue with translations and language. On my previous entry I wrote a modified URL and not the one that I'm really using (I did change it because I was writting in english) but the original URL was

 

index.php?id_category=3&controller=category#/precio-2-25

 

I you might guess, "precio" is "price" in spanish, and "precio" is what is displayed by Prestashop when I apply a filter by price on the layered navigation.

 

If I try to modify the URL constructed by Prestashop to different values, for example something like:

 

index.php?id_category=3&controller=category#/precio-2-27

 

then the price filter will be lost, which is the problem that I reported.

 

Looking at the code of blocklayered.php I found out that the strings "price" and "weight" are HARDCODED!!! Instead of using the values from the database depending on the language.

 

So when Prestashop BUILDS the URL when I filter is applied it does use the translated value (e.g. "precio"), but when it READS the values from the URL it uses hardcoded constants that are in english only (e.g. "price"). So it is an inconsistent use and therefore a bug.

 

The error in the code (in my opinion) is on blocklayered.php line 1719:

 

                    else if (in_array($attribute_name, array('price', 'weight')))

 

as it uses the hardcoded attribute names 'price' and 'weight'.

 

The correct code should get the filters of type slider from the database, get the names of the filter on the active language and then search for the name on the url, instead of searching only for the name of the filter in english language only.

 

The other solution would be to build the URL always in english instead of on the active language then it will always work also.

 

The bug really is that translation is used when building the URL but not used when reading the URL. It should either be translated always or never for both building and reading the URL.

 

  • Like 2
Link to comment
Share on other sites

Hi,

that is correct and does indeed work for the Price Slider.

Problem is that this doesn't work for other product features.

Any idea how that can be solved?

I want to use links for my Google Adwords campaign, so I can make a campaign for all products that have that one feature.

gr, Michaël

Edited by mser (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...