Default Sort By and Sort Order

Open to all! Ask other shopowners for help.
Post Reply
radhavallabh
Senior Contributor
Posts: 466
Joined: Tue Oct 27, 2020 4:09 am
Phoenix Version: 1.1.0.6
Has thanked: 29 times
Been thanked: 3 times

Default Sort By and Sort Order

Post by radhavallabh »

Hi dear;
I am using 1.1.04;
I need change default sort by and sort order.
I can see the default sort by is set in sortable_product_columns, still could not locate default sort by though.
But I am trying to figure out a way to change both for my default product listing without editing this core file.
Can you please help me on how to get this done...

Help is deeply appreciated,
Thank you in advance;
Warm Regds./
radhavallabh


Join The Code Co-op to get access to your library in the Code Co-op Forum
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Default Sort By and Sort Order

Post by ecartz »

In a hook that runs before the product listing module and after the category_path system hook, change the $_GET['sort'] if it is not set. E.g.

Code: Select all

class hook_shop_index_sort_products {

  function listen_siteWideStart() {
    if (isset($GLOBALS['category_depth']) && ('products' === $GLOBALS['category_depth']) && !isset($_GET['sort'])) {
      $_GET['sort'] = '1a';
    }
  }

}
The part that says 1a is going to be different based on how you ordered your columns and which one you want to be the default. Also, which direction you want to be the default.
radhavallabh
Senior Contributor
Posts: 466
Joined: Tue Oct 27, 2020 4:09 am
Phoenix Version: 1.1.0.6
Has thanked: 29 times
Been thanked: 3 times

Re: Default Sort By and Sort Order

Post by radhavallabh »

ecartz wrote: Sun Aug 24, 2025 12:43 pm In a hook that runs before the product listing module and after the category_path system hook, change the $_GET['sort'] if it is not set. E.g.

Code: Select all

class hook_shop_index_sort_products {

  function listen_siteWideStart() {
    if (isset($GLOBALS['category_depth']) && ('products' === $GLOBALS['category_depth']) && !isset($_GET['sort'])) {
      $_GET['sort'] = '1a';
    }
  }

}
The part that says 1a is going to be different based on how you ordered your columns and which one you want to be the default. Also, which direction you want to be the default.
Sorry for delay in reply;
Thank you so much dear :) ;
Very Warm Regds./
radhavallabh


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply