基本上,我需要每天自动生成一个客户的CSV文件。我已经尝试了几种方法,但它们太慢或者实际上已经耗尽了内存。
*1)通过循环遍历集合资源 *
有什么想法吗?
谢谢!
*1)通过循环遍历集合资源 *
$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和加载客户
$collection = Mage::getResourceModel('customer/customer_collection');
foreach($collection as $customer) {
$fullcustomer = Mage::getModel("customer/customer")->load($customer->getId());
echo $fullcustomer->getFirstname() . ",";
}
有什么想法吗?
谢谢!