Jump to content

Issue with product sorting by stock + faceted search module


x3n0m0rph

Recommended Posts

Hi,

 

I am using prestashop 1.7.2.4, live shop now, and I am not able to use faceted search module becouse is messing up products order in categories.

My settings:

 Shop Parameters -> Products -> Pagination -> Sort by: Product Quantity

If I enable the faceted search module, this sorting method will not work - products will be automaticly sorted by oldest products first. All other sorting methods will work fine.

This is a huge problem for me, becouse I have like 5.000 products and 60% of them are not in stock. I really need to show in stock products first. At the same time, I need Faceted Search to help my clients sort products easy.

Please help - this is a live shop and I can not find a fix for this!

Thank you

  • Like 1
Link to comment
Share on other sites

  • 5 months later...

Hey,

 

I've been looking in this issue also for a customer in the last days...

Found a work-a-round if it's still needed for you?

 

Open following file in \themes\your-theme\templates\catalog\_partials\sort-orders.tpl

 

In the Dropdown-menu code change from

<div class="dropdown-menu">
    {foreach from=$listing.sort_orders item=sort_order}
        <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>

To this

<div class="dropdown-menu">
    {foreach from=$listing.sort_orders item=sort_order}
        <a
          rel="nofollow"
          href="{$sort_order.url}"
          class="select-list "
        >
        {$sort_order.label}
      </a>
    {/foreach}
  </div>

Hope it helps!

Link to comment
Share on other sites

  • 5 months later...

Hi!!

I don't know if you resolved this problema, I had same problem in a shop with prestashop 1.7.4.4 version. I have been finding a solution, and I see that is a bug.

But I resolved it changing ps_facetedsearch.php. In line 1358 (aprox.)

change  (I comented all this).

        //if (!Validate::isOrderBy($order_by)) {
        //    $order_by = 'cp.position';
        //}

        //if (!Validate::isOrderWay($order_way)) {
        //    $order_way = 'ASC';
        //}
        
        //$order_clause = $order_by . ' ' . $order_way;

and i put this:

$order_clause = 'stock.quantity DESC';

And now order by quantity!!!

Sorry for my bas english.!!

 

  • Thanks 1
Link to comment
Share on other sites

  • 2 weeks later...
On 12/16/2018 at 12:39 AM, rastavmp said:

Hi!!

I don't know if you resolved this problema, I had same problem in a shop with prestashop 1.7.4.4 version. I have been finding a solution, and I see that is a bug.

But I resolved it changing ps_facetedsearch.php. In line 1358 (aprox.)

change  (I comented all this).

        //if (!Validate::isOrderBy($order_by)) {
        //    $order_by = 'cp.position';
        //}

        //if (!Validate::isOrderWay($order_way)) {
        //    $order_way = 'ASC';
        //}
        
        //$order_clause = $order_by . ' ' . $order_way;

and i put this:

$order_clause = 'stock.quantity DESC';

And now order by quantity!!!

Sorry for my bas english.!!

 

I perfectly fixed my problem with this

thank you so much!

Link to comment
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...