Knowledgebase

How to remove the "Sort by" menu from the product category page in PrestaShop

By default, PrestaShop displays on the product category pages of your store's frontend a Sort by drop-down menu from which customers can change the way in which the products in that category are ordered. If you don't want customers to be able to change the order of products, you can disable the Sort by function by removing the drop-down menu from the frontend of your PrestaShop.

You can do this by commenting out some code at the end of the product-sort.tpl file of the the store's theme. The exact code may be a bit different depending on the theme that you use. As an example we'll use the default theme that comes prepackaged with PrestaShop 1.6; its folder is called default-bootstrap. So if your application is installed in the root public_html directory on your PrestaShop hosting account, the path to the file on the account would be public_html/themes/default-bootstrap/product-sort.tpl. The piece of code that you have to comment out is fairly big; it's at the end of the file and starts with:

<form id="productsSortForm{if isset($paginationId)}_{$paginationId}{/if}" 
action="{$request|escape:'html':'UTF-8'}" class="productsSortForm">
	<div class="select selector1">

Then just find the closing form tag. So in our example the code ends with:

	</div>
</form>

To comment it out put an exclamation mark and two hyphens after the first bracket for that string of code (e.g. <!--form id) and two hyphens before the last bracket (e.g. </form-->). This will delete the Sort by drop-down menu from the frontend of your PrestaShop.

You can edit the file from the Files section of the Pixie control panel. Another way to do it is to download the file on your local computer using an FTP Client (e.g. FileZilla), edit it with a text editor (e.g. Notepad, Wordpad) and upload it back overwriting the old file.

If your PrestaShop version is older than 1.5, before you make any changes to the template file you should enable the Force compile option. To do this log in to the backend of your PrestaShop and go to Preferences tab>Performance sub-tab. You'll find the option there. After you modify the code, refresh the frontend of the site to see the result. Once you're done with the modifications disable the Force compile option. By default, PrestaShop 1.5 and newer versions are configured to automatically recompile modified template files, so you don't have to change any options (unless you have specifically changed the options so that modified files are not automatically recompiled).

Don't forget that updating the particular theme will overwrite any modifications made to the code of the theme's files. The same is true for the default prepackaged theme when you upgrade the whole application. So if you use the default theme that comes prepackaged with the application, it may be useful to create a child theme, then to switch to that theme and modify its files. For more information on this check out the article on how to create a child theme in PrestaShop. In any case you should keep a record of all modifications that you make.

Was this answer helpful?

 Print this Article

Also Read