Basically, I need to get a CSV file of my customers, generated automatically in a script every day. I've tried several ways, but they are too slow or actually exhausted of memory.
*1) foreach through collection resource *
$collection = Mage::getResourceModel('customer/customer_collection')
->addAttributeToSelect('email')
->addAttributeToSelect('created_at')
->joinAttribute('billing_company', 'customer_address/company', 'default_billing', null, 'left')
->joinAttribute('billing_street', 'customer_address/street', 'default_billing', null, 'left')
->joinAttribute('billing_postcode', 'customer_address/postcode', 'default_billing', null, 'left')
->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing', null, 'left')
->joinAttribute('billing_city', 'customer_address/city', 'default_billing', null, 'left')
->joinAttribute('billing_region', 'customer_address/region', 'default_billing', null, 'left')
->joinAttribute('billing_country_id', 'customer_address/country_id', 'default_billing', null, 'left');
foreach($collection as $customer) {
echo $customer->getFirstname() . ",";
}
2) foreach and load customer
$collection = Mage::getResourceModel('customer/customer_collection');
foreach($collection as $customer) {
$fullcustomer = Mage::getModel("customer/customer")->load($customer->getId());
echo $fullcustomer->getFirstname() . ",";
}
Any ideas?
Thanks!