Search result default sorting - by aryandco

This topic has 2 replies, 2 voices, and was last updated 3 years, 5 months ago ago by Rose Tyler

  • Avatar: aryandco
    aryandco
    Participant
    May 26, 2021 at 18:13

    How can I change the sorting for search results? The search results are now showing in random order but I want to change it to price ascending.

    1 Answer
    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    May 27, 2021 at 07:27

    Hello,

    There is no such option, by default.
    After the next update you will be able to use next code in your child-theme/functions.php

    add_filter('etheme_ajax_search_products_query', function ($args){
    	$args['meta_key'] = '_price';
    	$args['orderby'] = 'meta_value_num';
    	$args['order'] = 'ASC';
        return $args;
    });

    Order param will take products from low to high price but if you use ‘DESC’ then you will show products from high to low prices
    To have it now – you can add this code http://prntscr.com/13gurhw
    $args = apply_filters('etheme_ajax_search_products_query', $args);
    to your plugins/et-core-plugin/app/models/customizer/class-ajax-search.php
    and custom above to your child theme

    Regards

  • Viewing 2 results - 1 through 2 (of 2 total)

The issue related to '‘search result default sorting’' has been successfully resolved, and the topic is now closed for further responses

8theme customization service
We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.