Jump to content

Add link to category in quick search results


rtvt

Recommended Posts

Hello,

I need to add category link to quick search results. Default module modified to show product images. Now blocksearch.js part around it looks like this:

var width_ac_results =  $("#search_query_" + blocksearch_type).parent('form').width();
if (typeof ajaxsearch != 'undefined' && ajaxsearch && typeof blocksearch_type !== 'undefined' && blocksearch_type) {
$("#search_query_" + blocksearch_type).autocomplete(
search_url,
{
minChars: 3,
max: 10,
width: (width_ac_results > 0 ? width_ac_results : 500),
selectFirst: false,
scroll: false,
dataType: "json",
formatItem: function(data, i, max, value, term) {
if(data.image!=null)
return "<img src=\"" + baseDir + "img/p/" + data.image.split('').join('/')+"/" + data.image+ "-cart_default.jpg\" alt=\"" + value + "\" />" + value + "<span>" + data.cname + "</span>";
else
              
                return "<img src=\"" + baseDir + "img/p/none.gif\" alt=\"" + value + "\" />" + value;},
parse: function(data) {
var mytab = new Array();
for (var i = 0; i < data.length; i++)
mytab[mytab.length] = { data: data[i], value: data[i].pname };
return mytab;
},
extraParams: {
ajaxSearch: 1,
id_lang: id_lang
}
}
)
.result(function(event, data, formatted) {
$('#search_query_' + blocksearch_type).val(data.pname);
document.location.href = data.product_link;
});
}

So i need to add link to product category by click on "<span>" + data.cname + "</span>"; 

 

Can anybody help with it, please?

 

Regards

 

 

 

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...