daily pastebin goal
68%
SHARE
TWEET

Untitled

a guest Jul 19th, 2018 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. try{
  2.     //configure the collection filters.
  3.     $collection = Mage::getResourceModel('customer/customer_collection')
  4.     ->addAttributeToSelect('entity_id')
  5.     ->addAttributeToSelect('firstname')
  6.     ->addAttributeToSelect('email');
  7.  
  8.     //Add a page size to the result set.
  9.     $collection->setPageSize(50);
  10.     //discover how many page the result will be.
  11.     $pages = $collection->getLastPageNumber();
  12.     $currentPage = 1;
  13.     //This is the file to append the output to.
  14.     $fp = fopen('customers.csv', 'w');
  15.     $addedKeys = false;
  16.     do{
  17.          //Tell the collection which page to load.
  18.          $collection->setCurPage($currentPage);
  19.          $collection->load();
  20.          foreach ($collection as $customer){
  21.             $customerArray = $customer->toArray();
  22.  
  23.   $newordercollection = Mage::getModel("sales/order")->getCollection()->addFieldToFilter('customer_id',$customerArray['entity_id']);    
  24.   $collection->setOrder('entity_id', 'ASC');
  25.   $firstItem = $newordercollection->getFirstItem();
  26.   $orderID = $firstItem->getIncrementId();
  27.  
  28.             //write the collection array as a CSV.
  29.  
  30.             $customerREquiredArray['customer ID'] = $customerArray['entity_id'];
  31.             $customerREquiredArray['First name'] = $customerArray['firstname'];
  32.             $customerREquiredArray['Email'] = $customerArray['email'];          
  33.             $customerREquiredArray['order id']= $orderID;
  34.    
  35. $orderdate = $firstItem->getCreatedAtStoreDate()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
  36.    
  37. $orderdate = var_dump($newordercollection->getCreatedAt());
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top