krapo Posted May 13, 2017 Share Posted May 13, 2017 Hi everyone, I have an issue with Prestashop 1.7 (knew how to do with 1.6, but with the new one): I would like to remove "Relevance" from the list of Sort by options in the products listing page. Does someone have any clue about how to proceed? Many thanks, Noe Link to comment Share on other sites More sharing options...
lisandronob Posted May 27, 2017 Share Posted May 27, 2017 Hi, im looking for the same thing. You've made it? Thanks Link to comment Share on other sites More sharing options...
kellyriverstone Posted June 1, 2017 Share Posted June 1, 2017 (edited) Not sure about removing just 1 sort option...but the entire drop down menu can be removed by editing the file: ../themes/classic/templates/catalog/_partials/sort-orders.tpl modify the line: <span class="col-sm-3 col-md-3 hidden-sm-down sort-by">{l s='Sort by:' d='Shop.Theme'}</span> to be <span class="col-sm-3 col-md-3 hidden-sm-down sort-by">{l s=' ' d='Shop.Theme'}</span> then delete the rest of the file below this line. Make a backup of your original file 1st just in case. Edited June 1, 2017 by kellyriverstone (see edit history) 1 Link to comment Share on other sites More sharing options...
BSP21 Posted June 9, 2017 Share Posted June 9, 2017 I have been trying the same but can´t remove just one sort option. Still figuring out how to do it. Like kellyriverstone says yo can remove the entire dropdown, but I have done it in a different way. Edit this file: ../themes/classic/templates/catalog/_partials/products-top.tpl Delete or comment this lines: <div class="box-sort-by"> {block name='sort_by'} {include file='catalog/_partials/sort-orders.tpl' sort_orders=$listing.sort_orders} {/block} </div> After that it is recommended to delete the border-right and padding of the "total products" display div. You can do that editing the style.css of your template. In my case this is what i did: .products-selection .total-products p{ margin: 5px 0; /*border-right: 1px solid #666;*/ margin-right: 8px; padding-right:8px; line-height: 13px; } I have "commented" the line of the border and modified the margin-right and padding-right attributes. Hope it helps. Link to comment Share on other sites More sharing options...
BernardL Posted July 21, 2017 Share Posted July 21, 2017 In regards to the sort If I wanted to have one page which is also a category not sorted by Item Name and to be freely sorted by the order, i place how would I do that? Link to comment Share on other sites More sharing options...
littlegreenguy Posted July 27, 2018 Share Posted July 27, 2018 On 5/13/2017 at 4:15 AM, krapo said: Hi everyone, I have an issue with Prestashop 1.7 (knew how to do with 1.6, but with the new one): I would like to remove "Relevance" from the list of Sort by options in the products listing page. Does someone have any clue about how to proceed? Many thanks, Noe I have a temporary 'fix' - to comment out the relevant line in "/modules/ps_facetedsearch/src/Ps_FacetedsearchProductSearchProvider.php": private function getAvailableSortOrders() { return [ // (new SortOrder('product', 'position', 'asc'))->setLabel( // $this->module->getTranslator()->trans('Relevance', array(), 'Modules.Facetedsearch.Shop') // ), (new SortOrder('product', 'name', 'asc'))->setLabel( $this->module->getTranslator()->trans('Name, A to Z', array(), 'Shop.Theme.Catalog') ), (new SortOrder('product', 'name', 'desc'))->setLabel( $this->module->getTranslator()->trans('Name, Z to A', array(), 'Shop.Theme.Catalog') ), (new SortOrder('product', 'price', 'asc'))->setLabel( $this->module->getTranslator()->trans('Price, low to high', array(), 'Shop.Theme.Catalog') ), (new SortOrder('product', 'price', 'desc'))->setLabel( $this->module->getTranslator()->trans('Price, high to low', array(), 'Shop.Theme.Catalog') ), ]; } You should probably override the function for a more permanent fix, but pretty new to Prestashop, so not sure how! Hope that helps though if a little late to the party! 1 Link to comment Share on other sites More sharing options...
Kevin Posted January 9, 2020 Share Posted January 9, 2020 I would go for the following: In the tpl file sort-orders.tpl edit the following if you want to skip, for example, sort option position. <span class="col-sm-3 col-md-3 hidden-sm-down sort-by">{l s='Sort by:' d='Shop.Theme.Global'}</span> <div class="{if !empty($listing.rendered_facets)}col-sm-9 col-xs-8{else}col-sm-12 col-xs-12{/if} col-md-9 products-sort-order dropdown"> <button class="btn-unstyle select-title" rel="nofollow" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> {if isset($listing.sort_selected)}{$listing.sort_selected}{else}{l s='Select' d='Shop.Theme.Actions'}{/if} <i class="material-icons float-xs-right"></i> </button> <div class="dropdown-menu"> {foreach from=$listing.sort_orders item=sort_order} {if $sort_order.field == 'position'}{continue}{/if} <a rel="nofollow" href="{$sort_order.url}" class="select-list {['current' => $sort_order.current, 'js-search-link' => true]|classnames}" > {$sort_order.label} </a> {/foreach} </div> </div> The part that does it, is the following: {if $sort_order.field == 'position'}{continue}{/if} Here you can add other fields you want to exclude. Link to comment Share on other sites More sharing options...
e-market Posted November 17, 2020 Share Posted November 17, 2020 PS. 1.7.6.4 file -> /modules/ps_facetedsearch/src/Product/SearchProvider.php CODE TO REMOVE RELEVANT sort by private function getAvailableSortOrders() { $sortSalesDesc = new SortOrder('product', 'sales', 'desc'); //$sortPosAsc = new SortOrder('product', 'position', 'asc'); $sortNameAsc = new SortOrder('product', 'name', 'asc'); $sortNameDesc = new SortOrder('product', 'name', 'desc'); $sortPriceAsc = new SortOrder('product', 'price', 'asc'); $sortPriceDesc = new SortOrder('product', 'price', 'desc'); $translator = $this->module->getTranslator(); return [ $sortSalesDesc->setLabel( $translator->trans('Best Sellers', [], 'Modules.Facetedsearch.Shop') ), //$sortPosAsc->setLabel( // $translator->trans('Relevance', [], 'Modules.Facetedsearch.Shop') //), $sortNameAsc->setLabel( $translator->trans('Name, A to Z', [], 'Shop.Theme.Catalog') ), $sortNameDesc->setLabel( $translator->trans('Name, Z to A', [], 'Shop.Theme.Catalog') ), $sortPriceAsc->setLabel( $translator->trans('Price, low to high', [], 'Shop.Theme.Catalog') ), $sortPriceDesc->setLabel( $translator->trans('Price, high to low', [], 'Shop.Theme.Catalog') ), ]; } Link to comment Share on other sites More sharing options...
jgme Posted August 28, 2021 Share Posted August 28, 2021 Just put this snippet to your custom.css. The 3 stands for the 3rd item on the list. Simply adapt it. .dropdown-menu a:nth-of-type(3) {display:none;} Link to comment Share on other sites More sharing options...
Shenny Posted February 7, 2022 Share Posted February 7, 2022 (edited) On 1/9/2020 at 9:34 AM, Kevin said: <div class="dropdown-menu"> {foreach from=$listing.sort_orders item=sort_order} {if $sort_order.current} {assign var="currentSortUrl" value=$sort_order.url|regex_replace:"/&resultsPerPage=\d+$/":""} {/if} <a rel="nofollow" href="{$sort_order.url}" class="select-list dropdown-item {['current' => $sort_order.current, 'js-search-link' => true]|classnames}" > {$sort_order.label} </a> {/foreach} </div> Above is the code creating the dropdown menu and below code is how you can remove any option you choose or as many options as you want. <div class="dropdown-menu"> {foreach from=$listing.sort_orders item=sort_order} {if $sort_order.current} {assign var="currentSortUrl" value=$sort_order.url|regex_replace:"/&resultsPerPage=\d+$/":""} {/if} {if $sort_order.label == "Relevance, reverse"}{continue}{/if} <a rel="nofollow" href="{$sort_order.url}" class="select-list dropdown-item {['current' => $sort_order.current, 'js-search-link' => true]|classnames}" > {$sort_order.label} </a> {/foreach} </div> Here I use .label instead of position since position removed 2 options from my dropdown and not just the 1. Edited Kevins response above since I believe this to be the most suitable. The ones mentioning Facetedsearch were not suitable for me since I have this module disabled and $listing.sort_orders I believe is Prestashop default functionality. With that being said I have modified Kevin's answer to suit the question more and only remove 1 option from the dropdown menu. Edited February 7, 2022 by Shenny (see edit history) Link to comment Share on other sites More sharing options...
Santietsit Posted February 3 Share Posted February 3 Muy util - resuleto en 1 minuto siguiendo los pasos! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now