Magento - Adding admin massactions

Kevin Steen Hansen

Im kinda stuck in my development. Im trying to add a new mass action to the adminpanel for orders, but i always return 404. I have tried multiple methods but never succeeded.. Hope some of you can tell me what i am doing wrong and how to fix it.

My config.xml

<modules>
    <plusshop_shipmentcontrol>
        <version>0.1.0</version>
    </plusshop_shipmentcontrol>
</modules>

<global>
    <models>
        <shipmentcontrol>
            <class>Plusshop_ShipmentControl_Model</class>
        </shipmentcontrol>
    </models>
</global>

<admin>
    <routers>
        <shipmentcontrol>
            <use>admin</use>
            <args>
                <module>Plusshop_ShipmentControl</module>
                <frontName>shipmentcontrol</frontName>
            </args>
        </shipmentcontrol>
    </routers>
</admin>

<adminhtml>
    <events>
        <!-- Before rendering event -->
        <core_block_abstract_prepare_layout_before>
            <observers>
                <plusshop_shipmentcontrol_add>
                    <type>singleton</type>
                    <class>shipmentcontrol/observer</class>
                    <method>addMassExport</method>
                </plusshop_shipmentcontrol_add>
            </observers>
        </core_block_abstract_prepare_layout_before>
    </events>
</adminhtml>

My Model/Observer.php:

<?php

class Plusshop_ShipmentControl_Model_Observer
{
    public function addMassExport(Varien_Event_Observer $observer)
    {
        $block = $observer->getEvent()->getBlock();

        if($block instanceof Mage_Adminhtml_Block_Widget_Grid_Massaction && $block->getRequest()->getControllerName() == 'sales_order')
        {
            $block->addItem('shipmentcontrolall', array(
                'label' => 'Create all shipments (GLS, DAO)',
                'url' => Mage::app()->getStore()->getUrl('*/shipmentcontrol/massactions/index')
            ));
        }
    }
}

And finally my MassActionsController.php

<?php

require_once 'Mage/Adminhtml/controllers/Action.php';

class Plusshop_ShipmentControl_MassActionsController extends Mage_Adminhtml_Controller_Action {

    public function indexAction() {

        // $orderIds = $this->getRequest()->getPost('order_ids', array());

        $this->_redirect('adminhtml/sales_order/');

    }

}

Really hope some of you can tell what im doing wrong here? Feel like i tried everything but no luck. Did i misunderstood something or what is wrong?

Regards Kevin.

Gerard de Visser

Replace:

<admin>
    <routers>
        <shipmentcontrol>
            <use>admin</use>
            <args>
                <module>Plusshop_ShipmentControl</module>
                <frontName>shipmentcontrol</frontName>
            </args>
        </shipmentcontrol>
    </routers>
</admin>

with:

<admin>
    <routers>
        <adminhtml>
            <args>
                <modules>
                    <Plusshop_ShipmentControl after="Mage_Adminhtml">Plusshop_ShipmentControl</Plusshop_ShipmentControl>
                </modules>
            </args>
        </adminhtml>
    </routers>
</admin>

You should be able to visit your page at: yoururl.com/admin/massactions/index (replace /admin part if you use different path to admin).

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related