Backend Customer List Add & Sort By Company

CS Cart v.4.3.4 -
Looking to add new column to profile customer table and as hook instructions in the
/design/backend/templates/views/profiles/manage.tpl at line code 33/67, but common field 'company' is unable to sort by company.

Hooks:
1) my_changes/hooks/profiles/manage_data.override.tpl
{$user.company}

2) my_changes/hooks/profiles/manage_header.overide.tpl

{__("company")}{if $search.sort_by == "company"}{$c_icon nofilter}{else}{$c_dummy nofilter}{/if}

Link shows as follow:
admin.php?dispatch=profiles.manage&user_type=C&sort_by=company&sort_order=desc

[attachment=12398:Customers-Profile-Administration.png]

Any idea of what file(s) I'm missing to get it sorted by Company?

Customers-Profile-Administration.png

CS Cart v.4.3.4 -
Looking to add new column to profile customer table and as hook instructions in the
/design/backend/templates/views/profiles/manage.tpl at line code 33/67, but common field 'company' is unable to sort by company.

Hooks:
1) my_changes/hooks/profiles/manage_data.override.tpl
{$user.company}

2) my_changes/hooks/profiles/manage_header.overide.tpl

{__("company")}{if $search.sort_by == "company"}{$c_icon nofilter}{else}{$c_dummy nofilter}{/if}

Link shows as follow:
admin.php?dispatch=profiles.manage&user_type=C&sort_by=company&sort_order=desc

attachicon.gifCustomers-Profile-Administration.png

Any idea of what file(s) I'm missing to get it sorted by Company?

Hello! It's working correctly on default CS-Cart. Perhaps you have any custom modifications.

CS Cart v.4.3.4 -
Looking to add new column to profile customer table and as hook instructions in the
/design/backend/templates/views/profiles/manage.tpl at line code 33/67, but common field 'company' is unable to sort by company.

Hooks:
1) my_changes/hooks/profiles/manage_data.override.tpl
{$user.company}

2) my_changes/hooks/profiles/manage_header.overide.tpl

{__("company")}{if $search.sort_by == "company"}{$c_icon nofilter}{else}{$c_dummy nofilter}{/if}

Link shows as follow:
admin.php?dispatch=profiles.manage&user_type=C&sort_by=company&sort_order=desc

attachicon.gifCustomers-Profile-Administration.png

Any idea of what file(s) I'm missing to get it sorted by Company?

PM me temporary FTP access, our specialists will check the issue

We used debug mode and found that the query changes the ORDER BY to company_name instead of company. This variable is really the store company name. It should be ordering by the cscart_users.company field. Any idea which script maps the URL parameters to the actual SQL query?

SELECT cscart_users.user_id, cscart_users.user_login, cscart_users.is_root, cscart_users.timestamp, cscart_users.user_type, cscart_users.status, cscart_users.firstname, cscart_users.lastname, cscart_users.email, cscart_users.company, cscart_users.company_id, cscart_companies.company as company_name FROM cscart_users LEFT JOIN cscart_user_profiles ON cscart_user_profiles.user_id = cscart_users.user_id LEFT JOIN cscart_companies ON cscart_companies.company_id = cscart_users.company_id WHERE 1 AND cscart_users.user_type = 'C' GROUP BY cscart_users.user_id ORDER BY company_name asc LIMIT 0, 110

We used debug mode and found that the query changes the ORDER BY to company_name instead of company. This variable is really the store company name. It should be ordering by the cscart_users.company field. Any idea which script maps the URL parameters to the actual SQL query?

SELECT cscart_users.user_id, cscart_users.user_login, cscart_users.is_root, cscart_users.timestamp, cscart_users.user_type, cscart_users.status, cscart_users.firstname, cscart_users.lastname, cscart_users.email, cscart_users.company, cscart_users.company_id, cscart_companies.company as company_name FROM cscart_users LEFT JOIN cscart_user_profiles ON cscart_user_profiles.user_id = cscart_users.user_id LEFT JOIN cscart_companies ON cscart_companies.company_id = cscart_users.company_id WHERE 1 AND cscart_users.user_type = 'C' GROUP BY cscart_users.user_id ORDER BY company_name asc LIMIT 0, 110

The query is correct due to the following part:

... cscart_companies.company as company_name ...

No, this causes is to sort on the STORE company name when it should be the CUSTOMER company name.

If we compare it to a sort on Name or sort on email the ORDER BY is cscart_users.lastname, cscart_users.firstname and cscart_users.email which are correct. What we expect is for the query to be ORDER BY cscart_users.company. What we are getting is ORDER BY company_name.

In the first part of the query it selects cscart_users.company, but there are multiple JOINS and I wonder if they are messing with the query.

SELECT cscart_users.user_id, cscart_users.user_login, cscart_users.is_root, cscart_users.timestamp, cscart_users.user_type, cscart_users.status, cscart_users.firstname, cscart_users.lastname, cscart_users.email, cscart_users.company, cscart_users.company_id, cscart_companies.company as company_name FROM cscart_users LEFT JOIN cscart_user_profiles ON cscart_user_profiles.user_id = cscart_users.user_id LEFT JOIN cscart_companies ON cscart_companies.company_id = cscart_users.company_id WHERE 1 AND cscart_users.user_type = 'C' GROUP BY cscart_users.user_id ORDER BY cscart_users.lastname asc, cscart_users.firstname asc LIMIT 0, 10

SELECT cscart_users.user_id, cscart_users.user_login, cscart_users.is_root, cscart_users.timestamp, cscart_users.user_type, cscart_users.status, cscart_users.firstname, cscart_users.lastname, cscart_users.email, cscart_users.company, cscart_users.company_id, cscart_companies.company as company_name FROM cscart_users LEFT JOIN cscart_user_profiles ON cscart_user_profiles.user_id = cscart_users.user_id LEFT JOIN cscart_companies ON cscart_companies.company_id = cscart_users.company_id WHERE 1 AND cscart_users.user_type = 'C' GROUP BY cscart_users.user_id ORDER BY cscart_users.email asc LIMIT 0, 10

Think we found a solution which works. app\functions\fn.users.php

Lines 918 - 926 is the $sortings array. Last line is 'company' => "company_name",

We changed this to 'company' => "?:users.company",

Now it is sorting on the customer company name.

No, this causes is to sort on the STORE company name when it should be the CUSTOMER company name.

In this case you are right. Thank you for sharing the solution

Sorry for jumping on this thread, but it is the closest one I could find for what I need.

I added a custom profile field and I would like it to show up on the Customers view list and also be able to sort by it on this page. I have not tried using hooks and the my_changes add-on yet, but I have tried directly editing the /design/backend/templates/views/profiles/manage.tpl file. Nothing changes when I edit this file, even after I clear the cache in CS-cart and my server. This is the file that controls the Customers view correct?

Thank you in advance for any help you can provide.

Sorry for jumping on this thread, but it is the closest one I could find for what I need.

I added a custom profile field and I would like it to show up on the Customers view list and also be able to sort by it on this page. I have not tried using hooks and the my_changes add-on yet, but I have tried directly editing the /design/backend/templates/views/profiles/manage.tpl file. Nothing changes when I edit this file, even after I clear the cache in CS-cart and my server. This is the file that controls the Customers view correct?

Thank you in advance for any help you can provide.

Hello!

The file is correct. What did you change there? Do you have any add-ons related to users?

Hello!

The file is correct. What did you change there? Do you have any add-ons related to users?

I had the beta Responsive Backend add-on running. When I deactivated that, the changes were displayed.

Thanks!

Try to download and install latest version of the module here

https://marketplace.cs-cart.com/add-ons/site-management/responsive-admin-panel.html