I've been trying to do a very similar thing. We need names & emails for users. In the end, I managed to dig through the database and assemble a mySql query that:
- Pulls the 'name' field from the billing address
- Joins that with the user table and pulls that email address
You will have to determine whether this serves your purpose. There are some likely issues:
- The billing address may not be the user's actual name
- The billing address name may not be a name at all (many users stick the first line of their address in here)
- The email they create their account with may not be the one you want
But if it seems promising, here's the query I ran on the database:
SELECT
users.uid AS uid,
commerce_addr.entity_id AS profile_id,
commerce_addr.commerce_customer_address_name_line AS full_name,
users.mail AS email
FROM
field_data_commerce_customer_address AS commerce_addr
INNER JOIN commerce_customer_profile ON commerce_addr.entity_id = commerce_customer_profile.profile_id
INNER JOIN users ON commerce_customer_profile.uid = users.uid
WHERE
users.uid NOT IN (0,1,32,33,44) # undesirable admin/test users
GROUP BY email
ORDER BY full_name
Comments
I know this is an old topic but I was able to do this fairly easily, by using hook_views_data_alter to connect customer profiles to the user table:
<?php
/**
* Implements hook_views_data_alter().
*/
function MYMODULE_views_data_alter(&$data) {
if (isset($data['users'])) {
// Add a relationship for users' profiles
$data['users']['uid_commerce_customer_profile'] = array(
'title' => t('Customer profile'),
'help' => t('Relate customer profiles for the user they belong to. This relationship will return one record for each profile belonging to the user.'),
'relationship' => array(
'handler' => 'views_handler_relationship',
'base' => 'commerce_customer_profile',
'base field' => 'uid',
'field' => 'uid',
'label' => t('Profile'),
),
);
}
}
?>
This makes a 'Customer profile' Relationship available to any view that uses the Users table. Once the relationship is added to a view, all fields on the Customer Profile become available for output, filtering, sorting etc.