Jump to content
krapo

Remove item from "Sort by" function in products page

Recommended Posts

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

 

Share this post


Link to post
Share on other sites

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 by kellyriverstone (see edit history)

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites
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!

  • Like 1

Share this post


Link to post
Share on other sites

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">&#xE5C5;</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.

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More