Sort order of customers.php

Open to all! Ask other shopowners for help.
Post Reply
loop
Contributor
Posts: 253
Joined: Thu Mar 25, 2021 12:26 pm
Phoenix Version:
Has thanked: 7 times
Been thanked: 3 times

Sort order of customers.php

Post 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


Join The Code Co-op to get access to your library in the Code Co-op Forum
User avatar
burt
Core Team
Posts: 4551
Joined: Tue Oct 29, 2019 9:37 am
Phoenix Version: v1.1.0.8
Has thanked: 252 times
Been thanked: 412 times

Re: Sort oder of customers.php

Post by burt »

['id' => 'DESC']

should do it

or

'date_account_created'

would also work, no?
I am not here to build for you.
I am here to build with you. Let's help each other.
loop
Contributor
Posts: 253
Joined: Thu Mar 25, 2021 12:26 pm
Phoenix Version:
Has thanked: 7 times
Been thanked: 3 times

Re: Sort oder of customers.php

Post by loop »

thank you Burt!
yes it works: $customers_sql = $customer_data->add_order_by($customers_sql, ['date_account_created' => 'DESC']);
14Steve14
Senior Contributor
Posts: 923
Joined: Fri Oct 25, 2019 7:01 pm
Phoenix Version: v1.0.9.1
Has thanked: 17 times
Been thanked: 103 times

Re: Sort order of customers.php

Post 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?
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Sort order of customers.php

Post 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.
14Steve14
Senior Contributor
Posts: 923
Joined: Fri Oct 25, 2019 7:01 pm
Phoenix Version: v1.0.9.1
Has thanked: 17 times
Been thanked: 103 times

Re: Sort order of customers.php

Post by 14Steve14 »

@ecartz many thanks. I will have a go tomorrow and will look into the module you suggested.


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