Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $customerCount = 0;
- try
- {
- //configure the customer collection
- $collection = Mage::getResourceModel('customer/customer_collection')
- ->addAttributeToSelect('entity_id')
- ->addAttributeToSelect('firstname')
- ->addAttributeToSelect('lastname')
- ->addAttributeToSelect('email');
- //configure the order collection
- $ordercollection = Mage::getModel("sales/order")->getCollection();
- $ordercollection->getSelect()->join(
- 'sales_flat_order_item',
- '`sales_flat_order_item`.order_id=`main_table`.entity_id',
- array(
- 'skus' => new Zend_Db_Expr('group_concat(`sales_flat_order_item`.sku SEPARATOR ", ")')
- )
- )->group('main_table.customer_id');
- do
- {
- foreach ($collection as $customer)
- {
- foreach ($ordercollection as $data)
- {
- $product = $data->getSkus();
- }
- $customerArray = $customer->toArray();
- $customerREquiredArray['customer ID'] = $customerArray['entity_id'];
- $customerREquiredArray['First name'] = $customerArray['firstname'];
- $customerREquiredArray['Last name'] = $customerArray['lastname'];
- $customerREquiredArray['Email'] = $customerArray['email'];
- $customerREquiredArray['product'] = $product;
- }
- }
- }
Add Comment
Please, Sign In to add comment