Jump to content

Blocklayered Module Problem With Url When Set Price Input Field


Recommended Posts

When i choose input text field instead of slider for product price in my blocklayered' settings, this module automaticly adds price range to the url, when i check any other filter, and do not change price range.

http://attribute.ua/156-katalog#/proizvoditel-aurora/price-0-462298 

How to fix that? All links in the filter block are without adding the price to url, just like they should:

http://attribute.ua/156-katalog/proizvoditel-aurora

You can check and see it by yourself (better in incognito mode):

http://attribute.ua/156-katalog

 

Prestashop version is 1.6.0.6, blocklayered v1.10.9

If this problem doesn't exist in the last update, please let me know. We can't afford to update all stuff for now, since we have a lot of coding added by ourselves

post-1154611-0-44638800-1454079653_thumb.jpgpost-1154611-0-94971700-1454079774_thumb.jpg

Link to comment
Share on other sites

  • 2 weeks later...

First of all, find your blocklayered.js in your theme' folder. It can be, for example, /themes/default-bootstrap/js/modules/blocklayered/blocklayered.js

Then after these lines at the beginning of file

var ajaxQueries = new Array();
var ajaxLoaderOn = 0;
var sliderList = new Array();
var slidersInit = false;

add variable ind=0 : 

var ajaxQueries = new Array();
var ajaxLoaderOn = 0;
var sliderList = new Array();
var slidersInit = false;
var ind = 0;

then, in any free space place this tiny function

function findWithAttr(array, attr, value) {
	for(var i = 0; i < array.length; i += 1) {
		if(array[i][attr] === value) {
			ind = i;
		}
	}
}

Now we can use it! Find this string:

else if ($('#layered_'+sliderType+'_range_min').length)

It will be close to the end of function reloadContent(params_plus)

Replace this code:

else if ($('#layered_'+sliderType+'_range_min').length)
current_friendly_url += '/'+blocklayeredSliderName[sliderType]+'-'+$('#layered_'+sliderType+'_range_min').val()+'-'+$('#layered_'+sliderType+'_range_max').val();
				

with this one:

else if ($('#layered_'+sliderType+'_range_min').length){
findWithAttr(filters, 'type', sliderType);
if ((document.getElementById('layered_'+sliderType+'_range_min').value != filters[ind].min)  ||
(document.getElementById('layered_'+sliderType+'_range_max').value != filters[ind].max) ) {
current_friendly_url += '/price-'+$('#layered_'+sliderType+'_range_min').val()+'-'+$('#layered_'+sliderType+'_range_max').val();
}
}

That's it, don't forget to refresh javascript cache. (reload the page with combination Ctrl+Shift+R in Chrome or delete cache somehow according to your taste =) )

It works in PS 1.6.0.6 and in the newest 1.6.1.4

Edited by glux_perpetua (see edit history)
  • Like 1
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...