Admin customers.php

Open to all! Ask other shopowners for help.
Post Reply
heatherbell
Senior Contributor
Posts: 2540
Joined: Mon Oct 07, 2019 4:39 am
Phoenix Version:
Has thanked: 35 times
Been thanked: 243 times

Admin customers.php

Post by heatherbell »

Trying to change the default sort order for customers by changing this line:
https://github.com/CE-PhoenixCart/Phoen ... lt.php#L33
from:

Code: Select all

$customers_sql = $customer_data->add_order_by($customers_sql, ['id' => 'DESC']);
to:

Code: Select all

$customers_sql = $customer_data->add_order_by($customers_sql, ['date_last_logon' => 'DESC']);
This has unexpected result of sorting by 'date_account_created' instead.
Any pointers?


Join The Code Co-op to get access to your library in the Code Co-op Forum
Omar_one
Senior Contributor
Posts: 679
Joined: Fri Oct 25, 2019 5:06 pm
Phoenix Version: v1.0.8.16
Has thanked: 100 times
Been thanked: 56 times

Re: Admin customers.php

Post by Omar_one »

heatherbell wrote: Sun Jul 28, 2024 12:09 pm Trying to change the default sort order for customers by changing this line:
https://github.com/CE-PhoenixCart/Phoen ... lt.php#L33
from:

Code: Select all

$customers_sql = $customer_data->add_order_by($customers_sql, ['id' => 'DESC']);
to:

Code: Select all

$customers_sql = $customer_data->add_order_by($customers_sql, ['date_last_logon' => 'DESC']);
This has unexpected result of sorting by 'date_account_created' instead.
Any pointers?

Code: Select all

  $customers_sql = $customer_data->add_order_by($customers_sql, ['customers_info_date_of_last_logon' => 'DESC']);
and you need to

Code: Select all

 'customers_info_date_of_last_logon',
after

Code: Select all

 'date_last_logon',
I am not sure why the columns they are different on the file then database
heatherbell
Senior Contributor
Posts: 2540
Joined: Mon Oct 07, 2019 4:39 am
Phoenix Version:
Has thanked: 35 times
Been thanked: 243 times

Re: Admin customers.php

Post by heatherbell »

Omar_one wrote: Sun Jul 28, 2024 12:55 pmyou need to
No, already tried variations of that, it does not work.
Omar_one wrote: Sun Jul 28, 2024 12:55 pmyou need to
I am not sure why the columns they are different on the file then database
You'll see why in the SQL that is output. Did quite a lot of debugging trying to get something to work, for example:

Code: Select all

$customers_sql = $customer_data->add_order_by($customers_sql, ['date_last_logon' => 'DESC']);
gives:

Code: Select all

SQL Query: SELECT ci.*, co.*, ab.*, c.*, c.customers_id AS id, c.customers_firstname AS firstname, c.customers_lastname AS lastname, c.customers_email_address AS email_address, ab.entry_country_id AS country_id, ci.customers_info_date_account_created AS date_account_created, ci.customers_info_date_account_last_modified AS date_account_last_modified, ci.customers_info_date_of_last_logon AS date_last_logon, ci.customers_info_number_of_logons AS number_of_logons FROM customers c LEFT JOIN address_book ab ON c.customers_id = ab.customers_id AND c.customers_default_address_id = ab.address_book_id LEFT JOIN countries co ON ab.entry_country_id = co.countries_id INNER JOIN customers_info ci ON c.customers_id = ci.customers_info_id ORDER BY ci.customers_info_date_account_created DESC
Note ORDER BY ci.customers_info_date_account_created DESC at the end.

Your example gives:

Code: Select all

SQL Query: SELECT ci.*, co.*, ab.*, c.*, c.customers_id AS id, c.customers_firstname AS firstname, c.customers_lastname AS lastname, c.customers_email_address AS email_address, ab.entry_country_id AS country_id, ci.customers_info_date_account_created AS date_account_created, ci.customers_info_date_account_last_modified AS date_account_last_modified, ci.customers_info_date_of_last_logon AS date_last_logon, ci.customers_info_number_of_logons AS number_of_logons FROM customers c LEFT JOIN address_book ab ON c.customers_id = ab.customers_id AND c.customers_default_address_id = ab.address_book_id LEFT JOIN countries co ON ab.entry_country_id = co.countries_id INNER JOIN customers_info ci ON c.customers_id = ci.customers_info_id ORDER BY c.customers_id
Note ORDER BY c.customers_id at the end, even the DESC doesn't work with that.

My question is more, "why does 'date_last_logon' give unexpected and incorrect result?"
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Admin customers.php

Post by ecartz »

https://github.com/CE-PhoenixCart/Phoen ... hp#L78-L81

It's been a while since I worked on it. What is the criteria when you make that call.
heatherbell
Senior Contributor
Posts: 2540
Joined: Mon Oct 07, 2019 4:39 am
Phoenix Version:
Has thanked: 35 times
Been thanked: 243 times

Re: Admin customers.php

Post by heatherbell »

ecartz wrote: Mon Jul 29, 2024 12:47 pm https://github.com/CE-PhoenixCart/Phoen ... hp#L78-L81
What is the criteria when you make that call.
Sorry, don't understand that question or how to answer.
My original post refers to https://github.com/CE-PhoenixCart/Phoen ... lt.php#L33 and the ouput of admin>customers.php


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