Magento – Magento send Order update mails

email-templatesmagento-1.9sales-order

I am using Marketplace in my website. In here seller can able to Process the order. I given below the code

public function shipementorderAction(){
                $id = $this->getRequest()->getParam('id');

                $order = Mage::getModel('sales/order')->load($id);
                $order->setData('state', 'shipement');
                $order->setStatus('shipement');
                $history = $order->addStatusHistoryComment('', false);
                $history->setIsCustomerNotified(false);
                $order->save(); 

                $order->sendOrderUpdateEmail(true, null);

                $this->_getSession()->addSuccess(
                    $this->__('The order state has been changed.')
                );

                Mage::getSingleton('core/session') ->addSuccess('Order Updated Successfully'); $this->_redirectReferer();


                }

I used this code to send a email to customer

$order->sendOrderUpdateEmail(true, null);

How to send copy of email to that current seller? Like customer got a order status mail as well as seller also got copy of same mail

Best Answer

add this code in marketplace module etc/config.xml inside the global tag

<template>
            <email>
              <sales_email_order_custom_comment_template translate="label" module="sales">
                    <label>Order Update</label>
                    <file>sales/custom_order_update.html</file>
                    <type>html</type>
                </sales_email_order_custom_comment_template>
           </email>
  </template>

make copy of order_update.html and rename to custom_order_update.html

for sending the email add this code

    $emailTemplate  = Mage::getModel('core/email_template')
                                    ->loadDefault('sales_email_order_custom_comment_template');
                    $emailTemplate
                    ->setDesignConfig(array('area' => 'frontend', 'store' => $store->getId()));                                                  
                    $emailTemplate->setSenderName(Mage::getStoreConfig('trans_email/ident_general/name'));
                    $emailTemplate->setSenderEmail(Mage::getStoreConfig('trans_email/ident_general/email')); 
                    $emailTemplate->setTemplateSubject('Order Updated Order #'.$order->getIncrementId()); 
  $emailTemplateVariables['order'] = $order; 
                  $processedTemplate = $emailTemplate->getProcessedTemplate($emailTemplateVariables);
                $emailTemplate->send('emailhere','seller name', $emailTemplateVariables,$storeId=null);
Related Topic