0

Right now i am using Magento 1.9.1.

I am working around on the code so i can add new Status in the mass Actions select menu http://mymagento.com/index.php/admin/sales_order/index/key/944964552ee91bc0eeeb09f63a57c97e/ page.

Right now when we select some orders we have this "Actions" select menu to change the status of all selected orders.

Here you can see for which "Actions" select menu i am talking about:

enter image description here

I created new Order status.

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(''),

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" ?

Thanks in advance!

1

For this to work you would need to make your own module with Adminhtml controller. The controller would have an action like statusAction

require_once 'Mage/Adminhtml/controllers/Sales/OrderController.php';

class [Namespace]_[Module]_Adminhtml_Sales_OrderController 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/');
        }
    }

With a config.xml looking something like this

<config>    
    [...]
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <[Namespace]_[Module] before="Mage_Adminhtml">[Namespace]_[Module]_Adminhtml</[Namespace]_[Module]>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>
    [...]
</config>

Resulting in an url like: $this->getUrl('*/sales_order/status')

3
0

$this->getUrl('') give only admin url with without secret key.

And then that mean you need to add action and controllers.

As 'url' => $this->getUrl('*/sales_order/pdfdocs'), ,means your action controller class Mage_Adminhtml_Sales_OrderController function pdfinvoicesAction() you need an new action..means function here.

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.