I’m working on a custom Magento extension that performs mass updates on order status, however it is not sending the customer an email when their order is updated.
Config
<?xml version="1.0"?>
<config>
<modules>
<VivasIndustries_MassCustomStatusses>
<version>0.1.0</version>
</VivasIndustries_MassCustomStatusses>
</modules>
<admin>
<routers>
<masscustomstatusses>
<use>admin</use>
<args>
<module>VivasIndustries_MassCustomStatusses</module>
<frontName>masscustomstatusses</frontName>
</args>
</masscustomstatusses>
</routers>
</admin>
<global>
<models>
<sales>
<rewrite>
<order>VivasIndustries_MassCustomStatusses_Model_Order</order>
</rewrite>
</sales>
</models>
<blocks>
<adminhtml>
<rewrite>
<sales_order_grid>VivasIndustries_MassCustomStatusses_Block_Sales_Order_Grid</sales_order_grid>
</rewrite>
</adminhtml>
</blocks>
<sales>
<order>
<states>
<masscustom1 translate="label">
<label>Mass Custom Action 1</label>
<statuses>
<masscustom1 default="1"/>
</statuses>
<visible_on_front>1</visible_on_front>
</masscustom1>
<masscustom2 translate="label">
<label>Mass Custom Action 2</label>
<statuses>
<masscustom2 default="2"/>
</statuses>
<visible_on_front>2</visible_on_front>
</masscustom2>
<masscustom3 translate="label">
<label>Mass Custom Action 3</label>
<statuses>
<masscustom3 default="1"/>
</statuses>
<visible_on_front>1</visible_on_front>
</masscustom3>
<masscustom4 translate="label">
<label>Mass Custom Action 4</label>
<statuses>
<masscustom4 default="1"/>
</statuses>
<visible_on_front>1</visible_on_front>
</masscustom4>
<masscustom5 translate="label">
<label>Mass Custom Action 5</label>
<statuses>
<masscustom5 default="1"/>
</statuses>
<visible_on_front>1</visible_on_front>
</masscustom5>
<masscustom6 translate="label">
<label>Mass Custom Action 6</label>
<statuses>
<masscustom6 default="1"/>
</statuses>
<visible_on_front>1</visible_on_front>
</masscustom6>
<masscustom7 translate="label">
<label>Mass Custom Action 7</label>
<statuses>
<masscustom7 default="1"/>
</statuses>
<visible_on_front>1</visible_on_front>
</masscustom7>
<masscustom8 translate="label">
<label>Mass Custom Action 8</label>
<statuses>
<masscustom8 default="1"/>
</statuses>
<visible_on_front>1</visible_on_front>
</masscustom8>
<masscustom9 translate="label">
<label>Mass Custom Action 9</label>
<statuses>
<masscustom9 default="1"/>
</statuses>
<visible_on_front>1</visible_on_front>
</masscustom9>
<masscustom10 translate="label">
<label>Mass Custom Action 10</label>
<statuses>
<masscustom10 default="1"/>
</statuses>
<visible_on_front>1</visible_on_front>
</masscustom10>
</states>
</order>
</sales>
</global>
</config>
Controller
Here’s the method of the controller for mass order status changes:
public function NewMass1Action()
{
$orderIds = $this->getRequest()->getPost('order_ids', array());
$countHoldOrder = 0;
foreach ($orderIds as $orderId) {
$order = Mage::getModel('sales/order')->load($orderId);
if ($order->canHold()) {
$order->masscustom1()->save();
$countHoldOrder++;
}
}
if ($countHoldOrder) {
$this->_getSession()->addSuccess($this->__('%s order(s) have changed status.', $countHoldOrder));
}
$this->_redirectUrl(Mage::helper('adminhtml')->getUrl('adminhtml/sales_order/index'));
}
Model
Here is the method it calls for updating the order status:
public function masscustom1()
{
$this->setMasscustom1BeforeState($this->getState());
$this->setMasscustom1BeforeStatus($this->getStatus());
$this->setState(self::STATE_MASSCUSTOM1, true);
$orderId = isset($_POST['orderid']) ? $_POST['orderid'] : null;
$order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
$comment = '';
$order->sendOrderUpdateEmail(true, $comment);
return $this;
}
Here is what happens when I view an order whose status I changed by this method:
So, can you guys help me fix the problem and make this method send emails for the order status changes?