Magento query to select all customer info
-
22-10-2019 - |
Question
I am looking for a query with all the customer info that I can dump into a CSV from SQL. I am working with a broken site and the customer wants all the customer info.
Please don't write one yourself as I can do that, just seeing if anyone has one already written.
Solution
Just dump the SQL from
Mage::getResourceModel('customer/customer_collection')->addAttributeToSelect('*')->load(true);
OTHER TIPS
Have you tried using the Magento dataflow exporter for customers? Its in the admin interface under SYSTEM -> IMPORT/EXPORT -> DATAFLOW PROFILES. That will give you a CSV with all the customers and their details. But if you're looking to get all the orders for the customers as well as their details, you might want to try a free module - something like Blue Jaleppeno will do the trick: http://www.magentocommerce.com/magento-connect/blue-jalappeno-order-export.html
If the installation is broken. Copy the database, and run the database against a "vanilla install" of the same version of magento. Then use the typical dataflow profiles or Magmi or another tool to export your data you need.
Writing SQL to export data from Magento is very complex, and requires much more work than just fixing the problem using the above method. I would advise against writing SQL by hand for this task.
Here y'go:
$customerCollection = Mage::getResourceModel('customer/customer_collection')
->addAttributeToSelect('*')
->load(true);
$customerSqlQuery = $customerCollection
->getSelect()
->__toString();
That gives us the following SQL query:
SELECT `e`.* FROM `customer_entity` AS `e` WHERE (`e`.`entity_type_id` = '1');
That what you needed?