PrestaShop by default has got possibility to turn on someting like AJAX search. AJAX search is a nice feature that allows your customer to see the search hints. It's very usefull tool which increasing your store usability. By default this tool shows up to 10 products. If you want to change the number of the products (especially if you want to increase the number of them) you have to modify the block search module template files and also PrestaShop core (search class).
PrestaShop search tool and its hints
Modification of the core
In this case go to the /classes/ directory located in root dir of your PrestShop installation . Open the Search.php file. This is the search class - the most important thing in the whole "search" process. You've got there important functions related to the AJAX search feature. This is the code for AJAX search:
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); }
You have to change te LIMIT 10 value. You can increase or decrease the value of this param. This parameter defines the LIMIT of the results. So it is the MAXIMUM number of returned procuts. If you want to display 20 results - increase it to 20. So, i think that everything is clear in this case - append your changes and save the file.
It is time to the block search module modification
As in the header, now we will modify the search block module template (.tpl) files. In this case you have to open correct file. What I mean by correct file? I mean this file: modules/blocksearch/blocksearch-instantsearch.tpl. In this file you've got javascripts related to the both instantsearch and ajax search. Here is the function for search hints:
{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}
Highlighted value: max: 10 is a value of displayed products. You can increase and decrease value of this parameter. If you want to display 15 products in hints - just instead max: 10 use max: 15, if you want to show 20 products, use max: 20. Save changes and refresh your store front end. Here is an effect: