Page 1 of 1

Sort order of customers.php

Posted: Fri Jun 17, 2022 9:10 am
by loop
Hi All
i'm getting crazy about admin customers.php. i want only, that the standard sort_order whenn customers.php is open it should sort for customers_id DESC (so i see the newest registration on top)

On line 118 is: $customers_sql = $customer_data->add_order_by($customers_sql, ['sortable_name']);

whenn i change it to: $customers_sql = $customer_data->add_order_by($customers_sql, ['id'])." DESC"; it works, but that's for sure not the correct way. thank you for pointing me to the right way

Re: Sort oder of customers.php

Posted: Fri Jun 17, 2022 9:25 am
by burt
['id' => 'DESC']

should do it

or

'date_account_created'

would also work, no?

Re: Sort oder of customers.php

Posted: Fri Jun 17, 2022 10:02 am
by loop
thank you Burt!
yes it works: $customers_sql = $customer_data->add_order_by($customers_sql, ['date_account_created' => 'DESC']);

Re: Sort order of customers.php

Posted: Sat Mar 23, 2024 5:14 pm
by 14Steve14
Found this thread through a search.

Is there a way to sort the order of the customers to newest first in the admin customers list using a hook, rather than changing core code?

Re: Sort order of customers.php

Posted: Sat Mar 23, 2024 7:31 pm
by ecartz
14Steve14 wrote: Sat Mar 23, 2024 5:14 pm Is there a way to sort the order of the customers to newest first in the admin customers list using a hook, rather than changing core code?
Not that I know of, but the order is controlled by the sortable_name customer data module. The default install uses https://github.com/CE-PhoenixCart/Phoen ... name_2.php but you could install one that used a different sort. The sort order is defined at https://github.com/CE-PhoenixCart/Phoen ... hp#L61-L65 in the original file.

I.e. create a new cd_sortable_id_desc.php module that implements sortable_name and change the sort function accordingly. Uninstall the current module and install the new module.

S04e03 includes a module that already does this.

Re: Sort order of customers.php

Posted: Sat Mar 23, 2024 8:13 pm
by 14Steve14
@ecartz many thanks. I will have a go tomorrow and will look into the module you suggested.