Question

I'm running a Magento Commerce Cloud B2B, and I need to get a list of these data below.

  • Customer ID
  • Customer Name
  • Company Name
  • Company User Agreement

As I can't export a file with these pieces of information above via the admin panel, how could I do it via a MySQL query?

Was it helpful?

Solution

You can use MySQL INNER JOIN to do it. This script is going to help you with it:

SELECT customer_grid_flat.entity_id ,customer_grid_flat.name, customer_grid_flat.billing_company, company_erp.`is_end_user_agreement` FROM customer_grid_flat 
INNER JOIN company ON company.company_name = customer_grid_flat.billing_company
INNER JOIN company_erp ON company_erp.company_id = company.entity_id;

Magento 2 get customer data via MySQL query

Export SQL

To export this into a file you can run this code snippet below with the SQL file containing the script above:

mysql -h 127.0.0.1 -u magento -pmagento magento < customer-company-ua.sql > customer-company.csv

Convert it to CSV

To convert it to CSV separated by comma, you can run this command below instead.

mysql -h 127.0.0.1 -u magento -pmagento magento < customer-company-ua.sql | sed 's/\t/,/g' > customer-company.csv
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top