Created
June 2, 2014 03:42
-
-
Save isyan/2243af1e40df0eb07d6e to your computer and use it in GitHub Desktop.
get customer name and email and prompts for a download as a csv file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| require_once "app/Mage.php"; | |
| Mage::app(); | |
| header('Content-Type: text/csv; charset=utf-8'); | |
| header('Content-Disposition: attachment; filename=customer-feed.csv'); | |
| // create a file pointer connected to the output stream | |
| $output = fopen('php://output', 'w'); | |
| // output the column headings | |
| fputcsv($output, array('Name', 'Email')); | |
| $collection = Mage::getResourceModel('customer/customer_collection') | |
| ->addNameToSelect() | |
| ->addAttributeToSelect('email'); | |
| // loop over the rows, outputting them | |
| foreach($collection as $customer) { | |
| fputcsv($output, array($customer->getName(), $customer->getEmail())); | |
| } | |
| fclose($output); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment