1

I am using Magento 1.9.1 .

I am working on a new extension which is adding new custom mass status action here:

enter image description here

Here is my code:

/app/code/local/VivasIndustries/MassCustomStatusses/etc/config.xml :

<?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>
    <blocks>
        <adminhtml>
            <rewrite>
                <sales_order_grid>VivasIndustries_MassCustomStatusses_Block_Sales_Order_Grid</sales_order_grid>
            </rewrite>
        </adminhtml>
    </blocks> 
</global>
</config>

/app/code/local/VivasIndustries/MassCustomStatusses/Block/Sales/Order/Grid.php:

<?php
class VivasIndustries_MassCustomStatusses_Block_Sales_Order_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid
{   
    protected function _prepareMassaction()
    {
        parent::_prepareMassaction();
         
        // Append new mass action option 
        $this->getMassactionBlock()->addItem(
            'masscustomstatusses',
            array('label' => $this->__('New Mass 1'), 
                  'url'   => $this->getUrl('masscustomstatusses/controllers/NewMass') //this should be the url where there will be mass operation
            )
        );
    }
}

/app/code/local/VivasIndustries/MassCustomStatusses/controllers/IndexController.php:

<?php

class VivasIndustries_MassCustomStatusses_IndexController extends Mage_Adminhtml_Controller_Action
{

    public function NewMassAction()
    {
        // Update status here
        // Can fetch selected items with $this->getRequest()->getParam()

        die('Looks like it works');
    }

}

So here is what i've done by this guide: http://www.blog.magepsycho.com/adding-new-mass-action-to-admin-grid-in-magento/

When i select New Mass 1 and i click Sumbit i got error 404

enter image description here

I got this error on URL: http://mymagento.com/index.php/masscustomstatusses/controllers/NewMass/key/3ae4179b29ad706ef167e91bacf57c76/

Can you please help me fix this error?

NOTE: I've made this controller by instructions of this answer: Adding new custom mass order status action

Thanks in advance!

2
  • Not your question but a rewrite of the block is not the best course of action here as a lot of other extensions might also want to add there own mass actions. A better approach in my view is to observe core_block_abstract_prepare_layout_before and test if the block is Mage_Adminhtml_Block_Widget_Grid_Massaction Nov 29, 2014 at 23:20
  • Have you logged off admin, and then logged in again enabling your extension? Magento returns 404 in new adminhtml pages until user logs in again.
    – Dmytro
    Mar 10, 2015 at 15:58

2 Answers 2

1

Try changing

'url'   => $this->getUrl('masscustomstatusses/controllers/NewMass') 

to

'url'   => $this->getUrl('masscustomstatusses/index/NewMass') 

and also change the NewMassAction name to nameMassAction if it does not work. Remember to flush cache and log in and out to test this.

1

you took the wrong URL and got some naming issues.

Wrong Url:

'url' => $this->getUrl('masscustomstatusses/controllers/NewMass')

magento calls controllers by structure of the requesting url.

Your Route is named masscustomstatusses yout controller is named IndexController and your Action is called NewMassAction. In Magento the URL is built up by three parts:

module/controller/action which will should, in your case, result in : masscustomstatusses/index/NewMass so th egetUrl would look like:

$this->getUrl('masscustomstatusses/index/NewMass')

You should name your Action newMassAction instead of NewMassAction (and change the last parameter in the url of course) to avoid any naming issues.

Hope that helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.