Skip to content

Instantly share code, notes, and snippets.

@ceckoslab
Last active December 20, 2015 11:09
Show Gist options
  • Select an option

  • Save ceckoslab/6120823 to your computer and use it in GitHub Desktop.

Select an option

Save ceckoslab/6120823 to your computer and use it in GitHub Desktop.
Simple script, that shows / extract all email addresses of customers, who made orders in the Magento shop
<?php
/**
* @author Tsvetan Stoychev <ceckoslab@gmail.com>
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
ini_set('max_execution_time', 0);
define('MAGENTO_ROOT', getcwd());
$mageFilename = MAGENTO_ROOT . '/app/Mage.php';
require_once $mageFilename;
ini_set('display_errors', 1);
umask(0);
Mage::app();
$ordersCollection = Mage::getModel('sales/order')->getCollection()
->addFieldToSelect('customer_email');
$ordersCollection->getSelect()
->columns(array('orders_count' => 'COUNT(customer_email)'))
->group('customer_email');
echo '<pre>';
foreach($ordersCollection as $order) {
echo $order->getData('customer_email') . '<br />';
}
echo '</pre>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment