2

I am having a bit of trouble finding the code in Magento which relates to sending the new order email to the admin emails specified in the Configuration > Sales menu in the back-end.

Where is this coding please?

I would like to put in an if statement saying

if the order has items with attribute => value 
       then send to 1st email address;
 else
       send to 2nd email address`

What file should i be looking for to override and place this code into?

Thanks

1

You can find sendNewOrderEmail this method in Mage_Sales_Model_Order class. sendNewOrderEmail method responsible to send new order. that is.. this code should be under "$mailer" object.

$items = $this->getAllItems(); // get all products from order
    foreach ($items as $item){
        $product =    Mage::getModel('catalog/product')->loadByAttribute('sku',$item->getSku());
        if($product->getId()) {
            $emailInfo = Mage::getModel('core/email_info');

            if('if the order has items with attribute => value' ) {
                $emailInfo->addTo($email);
                $mailer->addEmailInfo($emailInfo);
            } else {
                $emailInfo->addTo($email);
                $mailer->addEmailInfo($emailInfo);
            }
        }
    }

Don't forget to rewrite this method before change logic.

| improve this answer | |
  • Thanks for the info! I found the method, but im not 100% sure where i should be putting the if statement i described above, could you help me out? Thanks – Tom Burman May 9 '14 at 5:40

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.