Magento – Add order status to mass update status menu

gridmagento-1.9massactionmodule

Right now I am using magento 1.9 and I'm trying to create a new extension, that is adding a custom order status to the Mass Update status select menu.

See the select menu "Actions" for which i am talking here:

enter image description here

When i opened:
/public_html/beta/app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php

I see the following code:

    $this->getMassactionBlock()->addItem('pdfcreditmemos_order', array(
         'label'=> Mage::helper('sales')->__('Print Credit Memos'),
         'url'  => $this->getUrl('*/sales_order/pdfcreditmemos'),
    ));

    $this->getMassactionBlock()->addItem('pdfdocs_order', array(
         'label'=> Mage::helper('sales')->__('Print All'),
         'url'  => $this->getUrl('*/sales_order/pdfdocs'),
    ));

These lines adds actions in this "Actions" select menu.

So in that manner i added my custom created Order status like this:

    $this->getMassactionBlock()->addItem('receive_in_our_office', array(
         'label'=> Mage::helper('sales')->__('Receive in our Office'),
         'url'  => $this->getUrl(''),
    ));

The problem is that when i select 'Receive in our Office' and press Submit just nothing happens. I am sure that this problem comes from my blank 'url' => $this->getUrl(''),

I was told that i have to create a new extension in order to make this thing work.

I created the following files:

/public_html/beta/app/code/community/VivasIndustries/MassUpdateCustomOS/controllers/Adminhtml/OSController.php

With content:

class MassUpdateCustomOS_Adminhtml_OSController extends Mage_Adminhtml_Sales_OrderController
    {
       public function statusAction()
        {
            $orders = $this->getRequest()->getPost('order_ids', array());
            foreach ($orders as $orderId)
            {
                $_order = Mage::getModel('sales/order')->load($orderId);
                $_order->setStatus("Receive in our Office");

                try {
                    $_order->save();
                } catch(Exception $e) {
                    Mage::getSingleton('adminhtml/session')->addError("{$e}"); 
                }
            }


            $this->_redirect('*/sales_order/');
        }
    }
?>  

Then i created:

/public_html/beta/app/code/community/VivasIndustries/MassUpdateCustomOS/etc/config.xml

With content:

<config>    
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <MassUpdateCustomOS before="Mage_Adminhtml">MassUpdateCustomOS_Adminhtml</MassUpdateCustomOS>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>
</config>

But when i go in my admin panel and open the Magento Connect Menager i don't see any module with name VivasIndustries or MassUpdateCustomOS installed ?

  1. Why i do not see this module as installed?
  2. So guys how i can properly set my 'url' => $this->getUrl(''), to the correct URL for my custom order status with code "receive_in_our_office" ?

Best Answer

Why i do not see this module as installed?

MagentoConnect lists the modules you installed via connect. If you coded it yourself it will not be listed. Beside this connect is (when you use it in production) totally crap and shouldn't be used. You don't want to ship any code you don't know what it does to production.

So guys how i can properly set my 'url' => $this->getUrl(''), to the correct URL for my custom order status with code receive_in_our_office ?

I'm not 100% sure, but I think this url is used to submit the form with all the data. The url should be $this->getUrl('admin/oS/status') then your controller should be called. Make sure, the data of all checked orders is send.