Page 1 of 1
Default Sort By and Sort Order
Posted: Sun Aug 24, 2025 10:36 am
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
Re: Default Sort By and Sort Order
Posted: Sun Aug 24, 2025 12:43 pm
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.
Re: Default Sort By and Sort Order
Posted: Tue Aug 26, 2025 6:56 am
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