MGLimhamn Posted October 22, 2013 Share Posted October 22, 2013 (edited) Hi, I currently have "Default order by": Product name set in an ascending order for my products in my products list. However, if I search for any products, the setting I set in the Back-Office doesn't apply to this one. As you can see in the image below, my product list gets sorted the way I want to, sorted by product name in alphabetical order. But the search page sorts it by the default "--" value which I removed as I don't want it, because I use A to Z as default. However, it displays the first option in the html select box: Price: Lowest first, even though it's not sorted by price. So, it shows Price: Lowest first, but sorts as the default "--", which I think sorts by the order you added the products? I'd like the search sort to work the same way as the product sort function. I tried to simply just enter selected="selected" on the Product name: A to Z but then the Price: Lowest first and Price: Highest first started to act weird. It works as it should, but the value in the select box changes back to Product name: A to Z after the sort is done. Can someone help me with this? All help is appreciated! Kind regards, MGLimhamn Edited October 25, 2013 by MGLimhamn (see edit history) Link to comment Share on other sites More sharing options...
MGLimhamn Posted October 24, 2013 Author Share Posted October 24, 2013 Anyone? Link to comment Share on other sites More sharing options...
vekia Posted October 24, 2013 Share Posted October 24, 2013 as far as i remember you can change it in searchController (controllers/admin/searchController) $search = Search::find($this->context->language->id, $query, $this->p, $this->n, $this->orderBy, $this->orderWay); Link to comment Share on other sites More sharing options...
MGLimhamn Posted October 24, 2013 Author Share Posted October 24, 2013 I only found a file called AdminSearchController.php in controllers/admin. And I couldn't find the code you said inside that file Link to comment Share on other sites More sharing options...
vekia Posted October 24, 2013 Share Posted October 24, 2013 so what ps version you use? Link to comment Share on other sites More sharing options...
MGLimhamn Posted October 24, 2013 Author Share Posted October 24, 2013 1.5.4.1 am I currently using. Link to comment Share on other sites More sharing options...
vekia Posted October 24, 2013 Share Posted October 24, 2013 hello open search module .tpl file and you will see there: <input type="hidden" name="orderby" value="position" /> <input type="hidden" name="orderway" value="desc" /> change orderby param value. for example: <input type="hidden" name="orderby" value="name" /> 2 Link to comment Share on other sites More sharing options...
MGLimhamn Posted October 24, 2013 Author Share Posted October 24, 2013 Thanks vekia, but which file do you mean? And where is it located? Link to comment Share on other sites More sharing options...
vekia Posted October 24, 2013 Share Posted October 24, 2013 sorry, i talked about this file: modules/blocksearch/blocksearch-top.tpl or if exists: /themes/YOUR_THEME/blocksearch/blocksearch-top.tpl Link to comment Share on other sites More sharing options...
MGLimhamn Posted October 25, 2013 Author Share Posted October 25, 2013 Thanks for the update. I tried to change: - modules/blocksearch/blocksearch-top.tpl - modules/blocksearch/blocksearch.tpl - themes/YOUR_THEME/blocksearch/blocksearch.tpl But none of them changed anything unfortunately. The URL is still the same: ?controller=search&orderby=position&orderway=desc Link to comment Share on other sites More sharing options...
vekia Posted October 25, 2013 Share Posted October 25, 2013 does the blocksearch-top.tpl file exist in your theme directory? after chainging .tpl files you have to recompile theme (adv. parameters > performance turn on force compile, turn of cache - then refresh your front office) Link to comment Share on other sites More sharing options...
MGLimhamn Posted October 25, 2013 Author Share Posted October 25, 2013 No, I only have blocksearch.tpl and translation folder in my themes directory. I know that, I already ticked force recompile on and no on cache. Still didn't work Link to comment Share on other sites More sharing options...
vekia Posted October 25, 2013 Share Posted October 25, 2013 can you share url to your website? i will inspect code there Link to comment Share on other sites More sharing options...
MGLimhamn Posted October 25, 2013 Author Share Posted October 25, 2013 http://shop.wowtoys.se/gb/ Thanks vekia. Link to comment Share on other sites More sharing options...
vekia Posted October 25, 2013 Share Posted October 25, 2013 ok the problem is in fact that you don't use blocksearch module, you use search tool located in blocktopmenu module. in this case you have to edit this file: /modules/blocktopmenu/blocktopmenu.tpl there is a code: {if $MENU_SEARCH} <li class="sf-search noBack" style="float:right"> <form id="searchbox" action="{$link->getPageLink('search')|escape:'html'}" method="get"> <p> <input type="hidden" name="controller" value="search" /> <input type="hidden" value="position" name="orderby"/> <input type="hidden" value="desc" name="orderway"/> <input type="text" name="search_query" value="{if isset($smarty.get.search_query)}{$smarty.get.search_query|escape:'htmlall':'UTF-8'}{/if}" /> </p> </form> </li> {/if} Link to comment Share on other sites More sharing options...
MGLimhamn Posted October 25, 2013 Author Share Posted October 25, 2013 (edited) Oh, I see. However, I edited the blocktopmenu.tpl file to: {if $MENU_SEARCH} <li class="sf-search noBack" style="float:right"> <form id="searchbox" action="{$link->getPageLink('search')}" method="get"> <p> <input type="hidden" name="controller" value="search" /> <input type="hidden" value="name" name="orderby"/> <input type="hidden" value="asc" name="orderway"/> <input type="text" placeholder="Sök leksaker..." onblur="javascript:if(this.placeholder=='')this.placeholder='Sök leksaker...';" onfocus="javascript:if(this.placeholder=='Sök leksaker...')this.placeholder='';" name="search_query" value="{if isset($smarty.get.search_query)}{$smarty.get.search_query|escape:'htmlall':'UTF-8'}{/if}" /> </p> </form> </li> {/if} But I still get the same result as before. Nothing has changed. EDIT: after I refreshed the page again (twice), it worked somehow. Thanks vekia for helping out as always! I'll mark it as solved Edited October 25, 2013 by MGLimhamn (see edit history) 1 Link to comment Share on other sites More sharing options...
vekia Posted October 25, 2013 Share Posted October 25, 2013 yeah! finally solved i checked it and it works like a charm thank you for your patience Link to comment Share on other sites More sharing options...
Ben90 Posted January 30, 2015 Share Posted January 30, 2015 (edited) ok the problem is in fact that you don't use blocksearch module, you use search tool located in blocktopmenu module. in this case you have to edit this file: /modules/blocktopmenu/blocktopmenu.tpl there is a code: {if $MENU_SEARCH} <li class="sf-search noBack" style="float:right"> <form id="searchbox" action="{$link->getPageLink('search')|escape:'html'}" method="get"> <p> <input type="hidden" name="controller" value="search" /> <input type="hidden" value="position" name="orderby"/> <input type="hidden" value="desc" name="orderway"/> <input type="text" name="search_query" value="{if isset($smarty.get.search_query)}{$smarty.get.search_query|escape:'htmlall':'UTF-8'}{/if}" /> </p> </form> </li> {/if} Hi Milos, I managed to change the search result default by lowest price first, but the instant result still showing based on "position" ; "desc". You know there's an instant result before we press enter. How can I change that into lowest price as well? I thank you in advance Edited January 30, 2015 by rukano (see edit history) Link to comment Share on other sites More sharing options...
rakepl Posted April 6, 2017 Share Posted April 6, 2017 Change <input type="hidden" value="position" name="orderby"/> by <input type="hidden" value="price" name="orderby"/> Link to comment Share on other sites More sharing options...
Recommended Posts