0

I need to get a list with the e-mail addresses of the customers who ordered products from a certain category, no matter if the customer is registered or not. Any help appreciated.

1 Answer 1

0
$purchaseCatagory = 5;

$categoyCollection = Mage::getModel('catalog/category')->load($purchaseCatagory)
    ->getProductCollection();

$collection = Mage::getResourceModel('sales/order_item_collection')
    ->addAttributeToFilter('product_id', array('in' => $categoyCollection->getAllIds()));

foreach ($collection as  $order) {
    $orders=$order->getOrder();
    echo $orders->getCustomerEmail();
}
8
  • unfortunately it does not show me any result. Thx anyways! Oct 25, 2016 at 13:39
  • Did you add your category id because i tested this code amd working for me Oct 25, 2016 at 14:24
  • yes, I added my category id but the screen remains blank. Oct 25, 2016 at 14:42
  • is there anything I could have missed or done wrong? Oct 25, 2016 at 14:44
  • Enable error log and check the error Oct 25, 2016 at 14:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.