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

$purchaseCatagory = 5;

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

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

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