Search code examples
prestashopprestashop-1.6

Products default sort not working on search.tpl - Prestashop 1.6.0.6


I set up in backoffice the default sort type to : in stock. this works for all pages except SearchController template file : search.tpl.

What can be the causes behind such dysfunctionning? I really don't know what part of code to deal with. Thanks everyone who already met such issue for advices.

Edit: I discovered that the link in the adress bar after click on search button is:

 website/index.phpcontroller=search&orderby=position&orderway=desc&search_query=design+40&submit_search=Rechercher

When I remove orderby=position&orderway=desc, the default behaviour works. I just need to remove this action from controller but still don't know how.


Solution

  • In template file, I found:

    <form method="get" action="{$link->getPageLink('search')|escape:'html'}" id="searchbox">
            <p>
                <label for="search_query_top"><!-- image on background --></label>
                <input type="hidden" name="controller" value="search" />
                <input type="hidden" name="orderby" value="quantity" />
                <input type="hidden" name="orderway" value="desc" />
                <input class="search_query" type="text" id="search_query_top" name="search_query" value="{$search_query|escape:'html':'UTF-8'|stripslashes}" />
                <input type="submit" name="submit_search" value="{l s='Search' mod='blocksearch'}" class="button" />
            </p>
    </form>
    

    As you see, I have already changed the value of the hidden input to quantity. Hope it helps.