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
Default Sort By and Sort Order
-
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
-
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
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. 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.
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';
}
}
}-
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
Sorry for delay in reply;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.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.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'; } } }
Thank you so much dear
Very Warm Regds./
radhavallabh