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.

$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! – Self Diagnostics Oct 25 '16 at 13:39
  • Did you add your category id because i tested this code amd working for me – Qaisar Satti Oct 25 '16 at 14:24
  • yes, I added my category id but the screen remains blank. – Self Diagnostics Oct 25 '16 at 14:42
  • is there anything I could have missed or done wrong? – Self Diagnostics Oct 25 '16 at 14:44
  • Enable error log and check the error – Qaisar Satti Oct 25 '16 at 14:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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