Order approve mail
-
28-09-2020 - |
Question
I am using Marketplace Extension in my Website. Once customer Bought Seller product in My website after that admin approve that product that time that seller got conformation mail for that everything is working fine.
But my problem is I want to add some custom value on that I can't able to find that file location can any one tell me where is the location of that mail
public function massStatusAction()
{
$orderIds = $this->getRequest()->getPost('order_ids', array());
$countOrder = 0;
foreach ($orderIds as $orderId) {
$order = Mage::getModel('sales/order')->load($orderId);
if($order->getStatus()=='pending'){
$order->setStatus('processing')->save();
$countOrder++;
// for mail to seller start
$_collection = Mage::getModel('marketplace/saleslist')->getCollection();
$_collection->addFieldToFilter('mageorderid',$orderId);
$_collection->addFieldToSelect('mageproownerid')
->distinct(true);
foreach($_collection as $collection){
$fetchsale = Mage::getModel('marketplace/saleslist')->getCollection();
$fetchsale->addFieldToFilter('mageorderid',$orderId);
$fetchsale->addFieldToFilter('mageproownerid',$collection->getMageproownerid());
$totalprice ='';
$orderinfo = '';
$style='style="font-size:11px;padding:3px 9px;border-bottom:1px dotted #cccccc";';
$tax="<tr><td ".$style."><h3>Tax</h3></td><td ".$style."></td><td ".$style."></td><td ".$style."></td></tr><tr>";
$options="<tr><td ".$style."><h3>Product Options</h3></td><td ".$style."></td><td ".$style."></td><td ".$style."></td></tr><tr><td ".$style."><b>Options</b></td><td ".$style."><b>Value</b></td><td ".$style."></td><td ".$style."></td></tr>";
foreach($fetchsale as $res){
$orderinfo = $orderinfo."<tr>
<td valign='top' align='left' ".$style." >".$res['mageproname']."</td>
<td valign='top' align='left' ".$style.">".Mage::getModel('catalog/product')->load($res['mageproid'])->getSku()."</td>
<td valign='top' align='left' ".$style." >".$res['magequantity']."</td>
<td valign='top' align='left' ".$style.">".Mage::app()->getStore()->formatPrice($res['mageproprice'])."</td>
</tr>";
foreach($order->getAllItems() as $item){
if($item->getProductId()==$res['mageproid']){
$taxAmount=Mage::app()->getStore()->formatPrice($item->getTaxAmount());
$tax=$tax."<tr><td ".$style."><b>Tax Amount</b></td><td ".$style."></td><td ".$style."></td><td ".$style.">".$taxAmount."</td></tr>";
$temp=$item->getProductOptions();
foreach($temp['options'] as $data){
$optionflag=1;
$options=$options."<tr><td ".$style."><b>".$data['label']."</b></td><td ".$style.">".$data['value']."</td><td ".$style."></td><td ".$style."></td></tr>";
}
}
}
$totalprice = $totalprice+$res['mageproprice'];
$userdata = Mage::getModel('customer/customer')->load($res['mageproownerid']);
$Username = $userdata['firstname'];
$useremail = $userdata['email'];
}
$shipcharge = $order->getShippingAmount();
if($item->getTaxAmount()>0){
$orderinfo=$orderinfo.$tax;
}
if($optionflag==1){
$orderinfo=$orderinfo.$options;
}
$orderinfo = $orderinfo."</tbody><tbody><tr>
<td align='right' style='padding:3px 9px' colspan='3'>Grandtotal</td>
<td align='right' style='padding:3px 9px' colspan='3'><span>".Mage::app()->getStore()->formatPrice($totalprice+$item->getTaxAmount())."</span></td>
</tr>";
$billingId = $order->getBillingAddress()->getId();
$billaddress = Mage::getModel('sales/order_address')->load($billingId);
$billinginfo = $billaddress['firstname'].'<br/>'.$billaddress['street'].'<br/>'.$billaddress['city'].' '.$billaddress['region'].' '.$billaddress['postcode'].'<br/>'.Mage::getModel('directory/country')->load($billaddress['country_id'])->getName().'<br/>T:'.$billaddress['telephone'];
if($order->getShippingAddress()!='')
$shippingId = $order->getShippingAddress()->getId();
else
$shippingId = $billingId;
$address = Mage::getModel('sales/order_address')->load($shippingId);
$shippinginfo = $address['firstname'].'<br/>'.$address['street'].'<br/>'.$address['city'].' '.$address['region'].' '.$address['postcode'].'<br/>'.Mage::getModel('directory/country')->load($address['country_id'])->getName().'<br/>T:'.$address['telephone'];
$payment = $order->getPayment()->getMethodInstance()->getTitle();
if($order->getShippingAddress()){
$shippingId = $order->getShippingAddress()->getId();
$address = Mage::getModel('sales/order_address')->load($shippingId);
$shippinginfo = $address['firstname'].'<br/>'.$address['street'].'<br/>'.$address['city'].' '.$address['region'].' '.$address['postcode'].'<br/>'.Mage::getModel('directory/country')->load($address['country_id'])->getName().'<br/>T:'.$address['telephone'];
$shipping = $order->getShippingDescription();
$shippinfo = $shippinginfo;
$shippingd = $shipping;
}
$emailTemp = Mage::getModel('core/email_template')->loadDefault('webkulorderinvoice');
$emailTempVariables = array();
$adminEmail=Mage::getStoreConfig('trans_email/ident_general/email');
$adminUsername = 'Admin';
if(isset($res['seller_order_id']) && $res['seller_order_id']!==NULL && $res['seller_order_id']!=="")
$emailTempVariables['myvar1'] = $res['seller_order_id'];
else
$emailTempVariables['myvar1'] = $res['magerealorderid'];
$emailTempVariables['myvar2'] = $res['cleared_at'];
$emailTempVariables['myvar4'] = $billinginfo;
$emailTempVariables['myvar5'] = $payment;
$emailTempVariables['myvar6'] = $shippinfo;
$emailTempVariables['myvar9'] = $shippingd;
$emailTempVariables['myvar8'] = $orderinfo;
$emailTempVariables['myvar3'] =$Username;
$processedTemplate = $emailTemp->getProcessedTemplate($emailTempVariables);
$emailTemp->setSenderName($adminUsername);
$emailTemp->setSenderEmail($adminEmail);
$emailTemp->send($useremail,$Username,$emailTempVariables);
}
}
}
Assign seller Sku
<?php $_item = $this->getItem() ?>
<?php /* Custom Code */?>
<?php $_collection = Mage::getModel('marketplace/saleslist')->getCollection();
//$_collection->addFieldToFilter('mageorderid',$order->getEntityId());
$_collection->addFieldToFilter('mageproid',$_item->getProductId());
foreach($_collection as $res){
$connectionresource = Mage::getSingleton('core/resource');
$readconnection = $connectionresource->getConnection('core_read');
$allrecord = $readconnection->select()->from(array('mpassignproduct'=>'marketplace_assignproduct'))->where('mpassignproduct.mpassignproduct_id=?', $res->getMpassignproductId());
$mpassignproduct =$readconnection->fetchAll($allrecord);
if(count($mpassignproduct)) {
foreach($mpassignproduct as $assignproduct)
{
$sku=$assignproduct['sku'];
}
}else {
$sku=$_item->getSku();
}
}
?>
<?php /* Custom Code */?>
How to call this code Assign seller sku in that massStatusAction()
Solution
public function massStatusAction()
{
$orderIds = $this->getRequest()->getPost('order_ids', array());
$countOrder = 0;
foreach ($orderIds as $orderId) {
$order = Mage::getModel('sales/order')->load($orderId);
if($order->getStatus()=='pending'){
$order->setStatus('processing')->save();
$countOrder++;
// for mail to seller start
$_collection = Mage::getModel('marketplace/saleslist')->getCollection();
$_collection->addFieldToFilter('mageorderid',$orderId);
$_collection->addFieldToSelect('mageproownerid')
->distinct(true);
foreach($_collection as $collection){
$fetchsale = Mage::getModel('marketplace/saleslist')->getCollection();
$fetchsale->addFieldToFilter('mageorderid',$orderId);
$fetchsale->addFieldToFilter('mageproownerid',$collection->getMageproownerid());
$totalprice ='';
$orderinfo = '';
$style='style="font-size:11px;padding:3px 9px;border-bottom:1px dotted #cccccc";';
$tax="<tr><td ".$style."><h3>Tax</h3></td><td ".$style."></td><td ".$style."></td><td ".$style."></td></tr><tr>";
$options="<tr><td ".$style."><h3>Product Options</h3></td><td ".$style."></td><td ".$style."></td><td ".$style."></td></tr><tr><td ".$style."><b>Options</b></td><td ".$style."><b>Value</b></td><td ".$style."></td><td ".$style."></td></tr>";
foreach($fetchsale as $res){
$_collection1 = Mage::getModel('marketplace/saleslist')->getCollection();
//$_collection->addFieldToFilter('mageorderid',$orderId);
$_collection1->addFieldToFilter('mageproid',$res['mageproid']);
foreach($_collection1 as $res1){
$connectionresource = Mage::getSingleton('core/resource');
$readconnection = $connectionresource->getConnection('core_read');
$allrecord = $readconnection->select()->from(array('mpassignproduct'=>'marketplace_assignproduct'))->where('mpassignproduct.mpassignproduct_id=?', $res1->getMpassignproductId());
$mpassignproduct =$readconnection->fetchAll($allrecord);
if(count($mpassignproduct)) {
foreach($mpassignproduct as $assignproduct)
{
$sku=$assignproduct['sku'];
}
}else {
$sku=$_item->getSku();
}
}
$orderinfo = $orderinfo."<tr>
<td valign='top' align='left' ".$style." >".$res['mageproname']."</td>
<td valign='top' align='left' ".$style.">".$sku."</td>
<td valign='top' align='left' ".$style." >".$res['magequantity']."</td>
<td valign='top' align='left' ".$style.">".Mage::app()->getStore()->formatPrice($res['mageproprice'])."</td>
</tr>";
foreach($order->getAllItems() as $item){
if($item->getProductId()==$res['mageproid']){
$taxAmount=Mage::app()->getStore()->formatPrice($item->getTaxAmount());
$tax=$tax."<tr><td ".$style."><b>Tax Amount</b></td><td ".$style."></td><td ".$style."></td><td ".$style.">".$taxAmount."</td></tr>";
$temp=$item->getProductOptions();
foreach($temp['options'] as $data){
$optionflag=1;
$options=$options."<tr><td ".$style."><b>".$data['label']."</b></td><td ".$style.">".$data['value']."</td><td ".$style."></td><td ".$style."></td></tr>";
}
}
}
$totalprice = $totalprice+$res['mageproprice'];
$userdata = Mage::getModel('customer/customer')->load($res['mageproownerid']);
$Username = $userdata['firstname'];
$useremail = $userdata['email'];
}
$shipcharge = $order->getShippingAmount();
if($item->getTaxAmount()>0){
$orderinfo=$orderinfo.$tax;
}
if($optionflag==1){
$orderinfo=$orderinfo.$options;
}
$orderinfo = $orderinfo."</tbody><tbody><tr>
<td align='right' style='padding:3px 9px' colspan='3'>Grandtotal</td>
<td align='right' style='padding:3px 9px' colspan='3'><span>".Mage::app()->getStore()->formatPrice($totalprice+$item->getTaxAmount())."</span></td>
</tr>";
$billingId = $order->getBillingAddress()->getId();
$billaddress = Mage::getModel('sales/order_address')->load($billingId);
$billinginfo = $billaddress['firstname'].'<br/>'.$billaddress['street'].'<br/>'.$billaddress['city'].' '.$billaddress['region'].' '.$billaddress['postcode'].'<br/>'.Mage::getModel('directory/country')->load($billaddress['country_id'])->getName().'<br/>T:'.$billaddress['telephone'];
if($order->getShippingAddress()!='')
$shippingId = $order->getShippingAddress()->getId();
else
$shippingId = $billingId;
$address = Mage::getModel('sales/order_address')->load($shippingId);
$shippinginfo = $address['firstname'].'<br/>'.$address['street'].'<br/>'.$address['city'].' '.$address['region'].' '.$address['postcode'].'<br/>'.Mage::getModel('directory/country')->load($address['country_id'])->getName().'<br/>T:'.$address['telephone'];
$payment = $order->getPayment()->getMethodInstance()->getTitle();
if($order->getShippingAddress()){
$shippingId = $order->getShippingAddress()->getId();
$address = Mage::getModel('sales/order_address')->load($shippingId);
$shippinginfo = $address['firstname'].'<br/>'.$address['street'].'<br/>'.$address['city'].' '.$address['region'].' '.$address['postcode'].'<br/>'.Mage::getModel('directory/country')->load($address['country_id'])->getName().'<br/>T:'.$address['telephone'];
$shipping = $order->getShippingDescription();
$shippinfo = $shippinginfo;
$shippingd = $shipping;
}
$emailTemp = Mage::getModel('core/email_template')->loadDefault('webkulorderinvoice');
$emailTempVariables = array();
$adminEmail=Mage::getStoreConfig('trans_email/ident_general/email');
$adminUsername = 'Admin';
if(isset($res['seller_order_id']) && $res['seller_order_id']!==NULL && $res['seller_order_id']!=="")
$emailTempVariables['myvar1'] = $res['seller_order_id'];
else
$emailTempVariables['myvar1'] = $res['magerealorderid'];
$emailTempVariables['myvar2'] = $res['cleared_at'];
$emailTempVariables['myvar4'] = $billinginfo;
$emailTempVariables['myvar5'] = $payment;
$emailTempVariables['myvar6'] = $shippinfo;
$emailTempVariables['myvar9'] = $shippingd;
$emailTempVariables['myvar8'] = $orderinfo;
$emailTempVariables['myvar3'] =$Username;
$processedTemplate = $emailTemp->getProcessedTemplate($emailTempVariables);
$emailTemp->setSenderName($adminUsername);
$emailTemp->setSenderEmail($adminEmail);
$emailTemp->send($useremail,$Username,$emailTempVariables);
}
}
}
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange