Jump to content

[Solved] Sort By Function not working on product list


Recommended Posts

Hi, I'm kinda new of Prestashop, and appreciate your work.

 

I'm using prestashop1.5.6.2 .

 

website address : http://hairpacks.com/index.php?id_category=8&controller=category

 

I'm having problem with sort by function. it doeson't work when I select anything on the dropdown menu.

 

I think when I first installed Prestashop it worked fine. But I did make several changes with templates and product controller and themes, and when I checked it yesterday it didn't work.

 

 

Here are what I have tried so far to fix the problem.

 

-Change the theme to default

-Replace the product-sort.tpl and product-list.tpl with default tpl files.

-reset the quick search module

 

But the problem wasn't solved.

 

Please give me some idea if you have any to solve my problem. Thanks!

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

SOLVED THE PROBLEM.

 

For some reasons, the javascript for the product sorting doesn't work for my site.

 

I had backed up, and deleted all files of my site, and reinstalled.

 

But when I update DB files, the sorting function doesn't work..

 

so anyway...

 

I just made up new javascript dropdown menu.

 

I'm sure there is better ways to do that,.

 

 

 

Here 's the solution

 

COMMENT FOLLOWED LINES in product-sort.tpl

<form id="productsSortForm{if isset($paginationId)}_{$paginationId}{/if}" action="{$request|escape:'htmlall':'UTF-8'}" class="productsSortForm">
	<p class="select">
		<label for="selectPrductSort{if isset($paginationId)}_{$paginationId}{/if}">{l s='Sort by'}</label>
		<select id="selectPrductSort{if isset($paginationId)}_{$paginationId}{/if}" class="selectProductSort">
			<option value="{$orderbydefault|escape:'htmlall':'UTF-8'}:{$orderwaydefault|escape:'htmlall':'UTF-8'}" {if $orderby eq $orderbydefault}selected="selected"{/if}>{l s='--'}</option>
			{if !$PS_CATALOG_MODE}
				<option value="price:asc" {if $orderby eq 'price' AND $orderway eq 'asc'}selected="selected"{/if}>{l s='Price: Lowest first'}</option>
				<option value="price:desc" {if $orderby eq 'price' AND $orderway eq 'desc'}selected="selected"{/if}>{l s='Price: Highest first'}</option>
			{/if}
			<option value="name:asc" {if $orderby eq 'name' AND $orderway eq 'asc'}selected="selected"{/if}>{l s='Product Name: A to Z'}</option>
			<option value="name:desc" {if $orderby eq 'name' AND $orderway eq 'desc'}selected="selected"{/if}>{l s='Product Name: Z to A'}</option>
			{if $PS_STOCK_MANAGEMENT && !$PS_CATALOG_MODE}
				<option value="quantity:desc" {if $orderby eq 'quantity' AND $orderway eq 'desc'}selected="selected"{/if}>{l s='In stock'}</option>
			{/if}
			<option value="reference:asc" {if $orderby eq 'reference' AND $orderway eq 'asc'}selected="selected"{/if}>{l s='Reference: Lowest first'}</option>
			<option value="reference:desc" {if $orderby eq 'reference' AND $orderway eq 'desc'}selected="selected"{/if}>{l s='Reference: Highest first'}</option>
		</select>
	</p>
</form>

AND ADD FOLLOWED LINES NEXT TO THE COMMENT

 

NOTE THAT YOU CHANGE 'YOURSITEURL' TO 'YOUR SITE DOMAIN.'

{if isset($smarty.get.id_category) && $smarty.get.id_category}
<form id="productsSortForm{if isset($paginationId)}_{$paginationId}{/if}" action="{$request|escape:'htmlall':'UTF-8'}" class="productsSortForm">
	<p class="select">
		<label for="selectPrductSort{if isset($paginationId)}_{$paginationId}{/if}">{l s='Sort by'}</label>
		<select id="selectPrductSort{if isset($paginationId)}_{$paginationId}{/if}" class="selectProductSort" onChange="window.document.location.href=this.options[this.selectedIndex].value;" value="GO">
			<option>Select One</option>
			<option value="http://YOURSITEURL/index.php?id_category={$smarty.get.id_category}&controller=category&orderby=price&orderway=asc">Price: Lowest first</option>
			<option value="http://YOURSITEURL/index.php?id_category={$smarty.get.id_category}&controller=category&orderby=price&orderway=desc">Price: Highest first</option>
			<option value="http://YOURSITEURL/index.php?id_category={$smarty.get.id_category}&controller=category&orderby=name&orderway=asc">Product Name: A to Z</option>
			<option value="http://YOURSITEURL/index.php?id_category={$smarty.get.id_category}&controller=category&orderby=name&orderway=desc">Product Name: Z to A</option>
			<option value="http://YOURSITEURL/index.php?id_category={$smarty.get.id_category}&controller=category&orderby=quantity&orderway=desc">In Stock</option>
			<option value="http://YOURSITEURL/index.php?id_category={$smarty.get.id_category}&controller=category&orderby=reference&orderway=asc">Reference: Lowest first</option>
			<option value="http://YOURSITEURL/index.php?id_category={$smarty.get.id_category}&controller=category&orderby=reference&orderway=desc">Reference: High first</option>
		</select>
	</p>
</form>
{elseif isset($smarty.get.id_supplier) && $smarty.get.id_supplier}

	<form id="productsSortForm{if isset($paginationId)}_{$paginationId}{/if}" action="{$request|escape:'htmlall':'UTF-8'}" class="productsSortForm">
	<p class="select">
		<label for="selectPrductSort{if isset($paginationId)}_{$paginationId}{/if}">{l s='Sort by'}</label>
		<select id="selectPrductSort{if isset($paginationId)}_{$paginationId}{/if}" class="selectProductSort" onChange="window.document.location.href=this.options[this.selectedIndex].value;" value="GO">
			<option>Select One</option>
			<option value="http://YOURSITEURL/index.php?id_supplier={$smarty.get.id_supplier}&controller=supplier&orderby=price&orderway=asc">Price: Lowest first</option>
			<option value="http://YOURSITEURL/index.php?id_supplier={$smarty.get.id_supplier}&controller=supplier&orderby=price&orderway=desc">Price: Highest first</option>
			<option value="http://YOURSITEURL/index.php?id_supplier={$smarty.get.id_supplier}&controller=supplier&orderby=name&orderway=asc">Product Name: A to Z</option>
			<option value="http://YOURSITEURL/index.php?id_supplier={$smarty.get.id_supplier}&controller=supplier&orderby=name&orderway=desc">Product Name: Z to A</option>
			<option value="http://YOURSITEURL/index.php?id_supplier={$smarty.get.id_supplier}&controller=supplier&orderby=quantity&orderway=desc">In Stock</option>
			<option value="http://YOURSITEURL/index.php?id_supplier={$smarty.get.id_supplier}&controller=supplier&orderby=reference&orderway=asc">Reference: Lowest first</option>
			<option value="http://YOURSITEURL/index.php?id_supplier={$smarty.get.id_supplier}&controller=supplier&orderby=reference&orderway=desc">Reference: High first</option>
		</select>
	</p>
</form>
Edited by hairpacks (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 1 year later...
×
×
  • Create New...