Page 1 of 1

Admin customers.php

Posted: Sun Jul 28, 2024 12:09 pm
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?

Re: Admin customers.php

Posted: Sun Jul 28, 2024 12:55 pm
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

Re: Admin customers.php

Posted: Sun Jul 28, 2024 1:05 pm
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?"

Re: Admin customers.php

Posted: Mon Jul 29, 2024 12:47 pm
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.

Re: Admin customers.php

Posted: Mon Jul 29, 2024 1:59 pm
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