Jump to content

[SOLVED] Change default sort order in search page


Recommended Posts

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.

post-515215-0-35991900-1382452334_thumb.jpg

 

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?

post-515215-0-56792000-1382452335_thumb.jpg

 

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 by MGLimhamn (see edit history)
Link to comment
Share on other sites

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" />
  • Like 2
Link to comment
Share on other sites

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

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

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 by MGLimhamn (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 1 year later...

 

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 by rukano (see edit history)
Link to comment
Share on other sites

  • 2 years later...
×
×
  • Create New...