Jump to content

[PARTIALY SOLVED]How to increase number of search results shown in the instant search?


Recommended Posts

Hello.

 

I'm using instant search on my website.There are exactly 3270 product indexed.

 

When I'm searching for some products it shows me 10 results. I would like to change this and get 20 or maybe more results shown.

 

How to do that?

 

P.S. check the printscreen below:

 

post-525426-0-62106900-1374574690_thumb.jpg

 

My second question would be why it takes around 7-9 seconds before instant search gives me suggestions or search results in other words?

 

You can go to www.dekom.co.rs and try it.

 

Thank you all in advance

Dean

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

i think that the solution is in the blocksearch-instantsearch.tpl file

you've got there:

if $ajaxsearch}
<script type="text/javascript">
// <![CDATA[
 $('document').ready( function() {
  $("#search_query_{$blocksearch_type}")
   .autocomplete(
 '{if $search_ssl == 1}{$link->getPageLink('search', true)}{else}{$link->getPageLink('search')}{/if}', {
  minChars: 3,
  max: 10,
  width: 500,
  selectFirst: false,
  scroll: false,
  dataType: "json",
  formatItem: function(data, i, max, value, term) {
   return 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].cname + ' > ' + data[i].pname };
   return mytab;
  },
  extraParams: {
   ajaxSearch: 1,
   id_lang: {$cookie->id_lang}
  }
 }
   )
   .result(function(event, data, formatted) {
 $('#search_query_{$blocksearch_type}').val(data.pname);
 document.location.href = data.product_link;
   })
 });
// ]]>
</script>
{/if}

 

as you can see, there is a variable:

max: 10,

 

i never tested this, but i suppose that this is the value of the number of results

Link to comment
Share on other sites

i've got bad news. my method works.

But you have to define also LIMIT in the class: Search.php

 

open the file classes/Search.php, you've got there:

 if ($ajax)
 {
  $sql = 'SELECT DISTINCT p.id_product, pl.name pname, cl.name cname,
  cl.link_rewrite crewrite, pl.link_rewrite prewrite '.$score.'
 FROM '._DB_PREFIX_.'product p
 INNER JOIN `'._DB_PREFIX_.'product_lang` pl ON (
  p.`id_product` = pl.`id_product`
  AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
 )
 '.Shop::addSqlAssociation('product', 'p').'
 INNER JOIN `'._DB_PREFIX_.'category_lang` cl ON (
  product_shop.`id_category_default` = cl.`id_category`
  AND cl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl').'
 )
 WHERE p.`id_product` '.$product_pool.'
 ORDER BY position DESC LIMIT 10';
  return $db->executeS($sql);
 }

increase the value of the LIMIT 10

now in the blocksearch-instatsearch.tpl file you have to define the number of results (max variable)

 

 

here is full step by step tutorial:

increase the number of the AJAX hint search results

Link to comment
Share on other sites

Beautiful Vekia.

 

You go ahead and add this to the tutorial you are making. It seems to me that I always found some stuff nobody tried before and you find a great and easy fix for it. We are working great together friend. Of course, you should take more credit then I but still great cooperation :)

 

OK this first part of this topic is solved. I guess I should have made separate threads but is there a reason for the delay problem in my second q?

 

Thanks.

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

×
×
  • Create New...