Guest User

Untitled

a guest
Jul 19th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. <?php
  2.  
  3. $customerCount = 0;
  4. try
  5. {
  6. //configure the customer collection
  7. $collection = Mage::getResourceModel('customer/customer_collection')
  8. ->addAttributeToSelect('entity_id')
  9. ->addAttributeToSelect('firstname')
  10. ->addAttributeToSelect('lastname')
  11. ->addAttributeToSelect('email');
  12.  
  13. //configure the order collection
  14. $ordercollection = Mage::getModel("sales/order")->getCollection();
  15. $ordercollection->getSelect()->join(
  16. 'sales_flat_order_item',
  17. '`sales_flat_order_item`.order_id=`main_table`.entity_id',
  18. array(
  19. 'skus' => new Zend_Db_Expr('group_concat(`sales_flat_order_item`.sku SEPARATOR ", ")')
  20. )
  21. )->group('main_table.customer_id');
  22.  
  23. do
  24. {
  25. foreach ($collection as $customer)
  26. {
  27. foreach ($ordercollection as $data)
  28. {
  29. $product = $data->getSkus();
  30. }
  31. $customerArray = $customer->toArray();
  32. $customerREquiredArray['customer ID'] = $customerArray['entity_id'];
  33. $customerREquiredArray['First name'] = $customerArray['firstname'];
  34. $customerREquiredArray['Last name'] = $customerArray['lastname'];
  35. $customerREquiredArray['Email'] = $customerArray['email'];
  36. $customerREquiredArray['product'] = $product;
  37. }
  38. }
  39. }
Add Comment
Please, Sign In to add comment