1

I want to send mail to seller after place order to seller product

<customerpartner_email_template>
                    <label>Admin mail to check that some product is sold</label>
                    <file>marketplacepartner/customer_partner.html</file>
                    <type>html</type>
                </customerpartner_email_template>

observer.php

<?php 

 $store = Mage::app()
            ->getWebsite()
            ->getDefaultGroup()
            ->getDefaultStoreId(); 
            $lastOrderId=1796;
            $order = Mage::getModel('sales/order')->load($lastOrderId);
     $_collection = Mage::getModel('marketplace/saleslist')->getCollection();
    $_collection->addFieldToFilter('mageorderid',$lastOrderId); 

    foreach($_collection as $res){
         $id=$res['mageproownerid'];

/*print_r($res);*/
//print_r($customerData);
   }
$customerData = Mage::getModel('customer/customer')->load($id);


 $emailTemplate  = Mage::getModel('core/email_template')
                                        ->loadDefault('customerpartner_email_template');
                        $emailTemplate
                        ->setDesignConfig(array('area' => 'frontend', 'store' => $store));                                                  
                        $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($customerData->getEmail(),$customerData->getFirstName(), $emailTemplateVariables,$storeId=null);


                    ?>

But i got this only, Even i got mis match order id also

enter image description here

mail template

<body style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
<div style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
<table cellspacing="0" cellpadding="0" border="0" height="100%" width="100%">
        <tr>
            <td align="" valign="top" style="padding:20px 0 20px 0">
                <!-- [ header starts here] -->
                <table bgcolor="FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0;">
                    <tr>
                        <td valign="top">
                            <a href="{{store url=""}}"><img src="{{skin url="images/logo_email.gif" _area='frontend'}}" alt="{{var store.getFrontendName()}}"  style="margin-bottom:10px;" border="0"/></a>
                        </td>
                    </tr>
                    <!-- [ middle starts here] -->
                    <tr>
                        <td valign="top">
                            <h1 style="font-size:22px; font-weight:normal; line-height:22px; margin:0 0 11px 0;">Dear {{var myvar2}},</h1>
                            <p style="font-size:12px; line-height:16px; margin:0 0 16px 0;">I would like to inform you that your product is been sold from our store.</p>
                            <p style="font-size:12px; line-height:16px; margin:0 0 8px 0;">Order ID: {{var myvar1}}.</p>
                            <p style="font-size:12px; line-height:16px; margin:0 0 8px 0;">Quantity Ordered: {{var myvar3}}.</p>
                            <p style="font-size:12px; line-height:16px; margin:0 0 8px 0;">Total Cost: {{var myvar4}}.</p>
                            <p style="border:1px solid #E0E0E0; font-size:12px; line-height:16px; margin:0 0 16px 0; 
                        </td>
                    </tr>
                    <tr>
                        <td bgcolor="#EAEAEA" align="center" style="background:#EAEAEA; text-align:center;"><center><p style="font-size:12px; margin:0;">Thank you </p></center></td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</div>
</body>

config.xml

<events>
            <catalog_product_delete_after>
                <observers>
                   <Webkul_Marketplace_Model_Observer>
                      <type>singleton</type>
                      <class>Webkul_Marketplace_Model_Observer</class>
                      <method>DeleteProduct</method>
                   </Webkul_Marketplace_Model_Observer>
               </observers>
            </catalog_product_delete_after>
            <customer_register_success>
                <observers>
                   <Webkul_Marketplace_Model_Observer>
                      <type>singleton</type>
                        <class>Webkul_Marketplace_Model_Observer</class>
                        <method>CustomerRegister</method>
                   </Webkul_Marketplace_Model_Observer>
               </observers>
            </customer_register_success>
            <customer_delete_commit_after>
                <observers>
                    <Webkul_Marketplace_Model_Observer>
                        <class>Webkul_Marketplace_Model_Observer</class>
                        <method>deleteCustomer</method>
                    </Webkul_Marketplace_Model_Observer>
                </observers>
            </customer_delete_commit_after>
            <sales_order_place_after>
              <observers>
               <Webkul_Marketplace_Model_Observer>
                <type>singleton</type>
                 <class>Webkul_Marketplace_Model_Observer</class>
                  <method>afterPlaceOrder</method>
               </Webkul_Marketplace_Model_Observer>
              </observers>
            </sales_order_place_after>

            <sales_order_invoice_save_after>
                <observers>
                    <Webkul_Marketplace_Model_Observer>
                        <class>Webkul_Marketplace_Model_Observer</class>
                        <method>checkInvoiceSubmit</method>
                    </Webkul_Marketplace_Model_Observer>
                </observers>
            </sales_order_invoice_save_after>
            <adminhtml_customer_save_after>
                <observers>
                    <Webkul_Marketplace_Model_Observer>
                        <type>singleton</type>
                        <class>Webkul_Marketplace_Model_Observer</class>
                        <method>afterSaveCustomer</method>
                    </Webkul_Marketplace_Model_Observer>
               </observers>
            </adminhtml_customer_save_after>
            <sales_order_save_commit_after>
                <observers>
                    <Webkul_Marketplace_Model_Observer>
                        <class>Webkul_Marketplace_Model_Observer</class>
                        <method>commissionCalculationOnComplete</method>
                    </Webkul_Marketplace_Model_Observer>
                </observers>
            </sales_order_save_commit_after>
        </events>
<template>
            <email>
                <adminnotifymoney>
                    <label>Admin Notify For Credit</label>
                    <file>marketplacepartner/notifyadminformoney.html</file>
                    <type>html</type>
                </adminnotifymoney>
                <partnerrequest>
                    <label>Partner Request</label>
                    <file>marketplacepartner/partnerrequest.html</file>
                    <type>html</type>
                </partnerrequest>
                <partnerapprove>
                    <label>Partner Approved</label>
                    <file>marketplacepartner/partnerapprove.html</file>
                    <type>html</type>
                </partnerapprove>
                <partnerdisapprove>
                    <label>Partner Disapprove</label>
                    <file>marketplacepartner/partnerdisapprove.html</file>
                    <type>html</type>
                </partnerdisapprove>
                <partnerdeny>
                    <label>Partner Deny</label>
                    <file>marketplacepartner/denypartnermail.html</file>
                    <type>html</type>
                </partnerdeny>
                <productdeny>
                    <label>Product Deny</label>
                    <file>marketplacepartner/productdenymail.html</file>
                    <type>html</type>
                </productdeny>
                <partnercreditinfo>
                    <label>partner Notify for Credit</label>
                    <file>marketplacepartner/partnercreditinfo.html</file>
                    <type>html</type>
                </partnercreditinfo>
                <approveproduct>
                    <label>Approve My Product</label>
                    <file>marketplacepartner/admininformnewpro.html</file>
                    <type>html</type>
                </approveproduct>
                <customerpartner_email_template>
                    <label>Admin mail to check that some product is sold</label>
                    <file>marketplacepartner/customer_partner.html</file>
                    <type>html</type>
                </customerpartner_email_template>
                <customerpartner_email>
                    <label>Notify Partner when its product sold</label>
                    <file>marketplacepartner/notifycheckoutpartner.html</file>
                    <type>html</type>
                </customerpartner_email>
                <requesttobecomepartner_email>
                    <label>Notify Admin to make me partner</label>
                    <file>marketplacepartner/webkulcustomerpartnewreqest.html</file>
                    <type>html</type>
                </requesttobecomepartner_email>
                <querypartner_email>
                    <label>Ask question from partner for its particular product</label>
                    <file>marketplacepartner/webkulquerypartneremail.html</file>
                    <type>html</type>
                </querypartner_email>
                <askquerypartner_email>
                    <label>Ask question from partner</label>
                    <file>marketplacepartner/askquerypartneremail.html</file>
                    <type>html</type>
                </askquerypartner_email>                
                <queryadminemail>
                    <label>Ask question from admin by seller</label>
                    <file>marketplacepartner/webkulqueryadminemail.html</file>
                    <type>html</type>
                </queryadminemail>
                <whenproductapproved>
                    <label>When the product is Approved mail send to partner</label>
                    <file>marketplacepartner/admininapprovedit.html</file>
                    <type>html</type>
                </whenproductapproved>
                <orderinvoice>
                    <label>When invoice is created for an order</label>
                    <file>marketplacepartner/partener_order_invoice.html</file>
                    <type>html</type>
                </orderinvoice> 
                <webkulorderinvoice>
                    <label>When invoice is created for an order</label>
                    <file>marketplacepartner/webkul_order_invoice.html</file>
                    <type>html</type>
                </webkulorderinvoice>
                <sellertransactionmail>
                    <label>When transaction is created by for seller's order</label>
                    <file>marketplacepartner/sellertransactionmail.html</file>
                    <type>html</type>
                </sellertransactionmail>
            </email>            
        </template>

<rewrite>
                    <customer_edit_tabs>Webkul_Marketplace_Block_Adminhtml_Customer_Edit_Tabs</customer_edit_tabs>
                </rewrite>

commissionCalculationOnComplete

public function commissionCalculationOnComplete($observer){
        $order = $observer->getOrder();
        if($order->getState() == Mage_Sales_Model_Order::STATE_COMPLETE){
            Mage::getModel('marketplace/saleslist')->getCommsionCalculation($order);
        }

        $store = Mage::app()
            ->getWebsite()
            ->getDefaultGroup()
            ->getDefaultStoreId(); 
            $lastOrderId=1796;
            $order = Mage::getModel('sales/order')->load($lastOrderId);
     $_collection = Mage::getModel('marketplace/saleslist')->getCollection();
    $_collection->addFieldToFilter('mageorderid',$lastOrderId); 

    foreach($_collection as $res){
         $id=$res['mageproownerid'];

/*print_r($res);*/
//print_r($customerData);
   }
$customerData = Mage::getModel('customer/customer')->load($id);


 $emailTemplate  = Mage::getModel('core/email_template')
                                        ->loadDefault('customerpartner_email_template');
                        $emailTemplate
                        ->setDesignConfig(array('area' => 'frontend', 'store' => $store));                                                  
                        $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['myvar1'] = $order->getIncrementId();
                    $emailTemplateVariables['myvar2'] =$customerData->getFirstName();
           $emailTemplateVariables['myvar3'] =$order->getData('total_qty_ordered');
     $emailTemplateVariables['myvar4'] =$order->getGrandTotal();
      $emailTemplateVariables['order'] = $order; 
                      $processedTemplate = $emailTemplate->getProcessedTemplate($emailTemplateVariables);
                    $emailTemplate->send($customerData->getEmail(),$customerData->getFirstName(), $emailTemplateVariables,$storeId=null);
    }
    }
  • marketplacepartner/customer_partner.html paste that template too – Qaisar Satti Jan 13 '16 at 10:26
  • check my updated question – Magento 2 Jan 13 '16 at 10:28
1

added your require vairable check it

 $store = Mage::app()
            ->getWebsite()
            ->getDefaultGroup()
            ->getDefaultStoreId(); 
            $lastOrderId= $observer->getOrder()->getId(); //order id pass here
            $order = Mage::getModel('sales/order')->load($lastOrderId);
     $_collection = Mage::getModel('marketplace/saleslist')->getCollection();
    $_collection->addFieldToFilter('mageorderid',$lastOrderId); 

    foreach($_collection as $res){
         $id=$res['mageproownerid'];

/*print_r($res);*/
//print_r($customerData);
   }
$customerData = Mage::getModel('customer/customer')->load($id);


 $emailTemplate  = Mage::getModel('core/email_template')
                                        ->loadDefault('customerpartner_email_template');
                        $emailTemplate
                        ->setDesignConfig(array('area' => 'frontend', 'store' => $store));                                                  
                        $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['myvar1'] = $order->getIncrementId();
                    $emailTemplateVariables['myvar2'] =$customerData->getFirstName();
           $emailTemplateVariables['myvar3'] =$order->getData('total_qty_ordered');
     $emailTemplateVariables['myvar4'] =$order->getGrandTotal();
      $emailTemplateVariables['order'] = $order; 
                      $processedTemplate = $emailTemplate->getProcessedTemplate($emailTemplateVariables);
                    $emailTemplate->send($customerData->getEmail(),$customerData->getFirstName(), $emailTemplateVariables,$storeId=null);
|improve this answer|||||
  • last order id can i keep it 1796 it self – Magento 2 Jan 13 '16 at 10:54
  • How to get in this Order ID: . Quantity Ordered: . Total Cost: . – Magento 2 Jan 13 '16 at 10:58
  • i think in observer you added the code.. for getting the order id – Qaisar Satti Jan 13 '16 at 11:05
  • If i add this code i din't got any mail if its 1796 i got a mail what ill do but order id is mismatch – Magento 2 Jan 13 '16 at 11:06
  • updated the code check it.... – Qaisar Satti Jan 13 '16 at 11:07

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.