Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try{
- //configure the collection filters.
- $collection = Mage::getResourceModel('customer/customer_collection')
- ->addAttributeToSelect('entity_id')
- ->addAttributeToSelect('firstname')
- ->addAttributeToSelect('email');
- //Add a page size to the result set.
- $collection->setPageSize(50);
- //discover how many page the result will be.
- $pages = $collection->getLastPageNumber();
- $currentPage = 1;
- //This is the file to append the output to.
- $fp = fopen('customers.csv', 'w');
- $addedKeys = false;
- do{
- //Tell the collection which page to load.
- $collection->setCurPage($currentPage);
- $collection->load();
- foreach ($collection as $customer){
- $customerArray = $customer->toArray();
- $newordercollection = Mage::getModel("sales/order")->getCollection()->addFieldToFilter('customer_id',$customerArray['entity_id']);
- $collection->setOrder('entity_id', 'ASC');
- $firstItem = $newordercollection->getFirstItem();
- $orderID = $firstItem->getIncrementId();
- //write the collection array as a CSV.
- $customerREquiredArray['customer ID'] = $customerArray['entity_id'];
- $customerREquiredArray['First name'] = $customerArray['firstname'];
- $customerREquiredArray['Email'] = $customerArray['email'];
- $customerREquiredArray['order id']= $orderID;
- $orderdate = $firstItem->getCreatedAtStoreDate()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
- $orderdate = var_dump($newordercollection->getCreatedAt());
Add Comment
Please, Sign In to add comment