Ok, this is the follow up to a other question of mine. I just can't figure out the last detail.
I created a custom extension to set a order status to "Ready for Pickup". The button shows and is clickable but does not generate the correct action.
/app/code/local/Mymodule/Pickup/etc/config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Mymodule_Pickup>
<version>0.0.1</version>
</Mymodule_Pickup>
</modules>
<global>
<blocks>
<adminhtml>
<rewrite>
<sales_order_view>Mymodule_Pickup_Block_Adminhtml_Sales_Order_View</sales_order_view>
</rewrite>
</adminhtml>
</blocks>
</global>
</config>
/app/code/local/Mymodule/Pickup/controllers/Adminhtml/IndexController.php
<?php
class Mymodule_Pickup_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action
public function pickupAction()
{
$orderId = $this->getRequest()->getParam('order_id');
$order = Mage::getModel('sales/order')->load($orderId);
$order->setStatus("pickup_ready");
$order->save();
// redirect to your sales order view page back
}
?>
/app/code/local/Mymodule/Pickup/Block/Adminhtml/Sales/Order/View.php
<?
class Mymodule_Pickup_Block_Adminhtml_Sales_Order_View extends Mage_Adminhtml_Block_Sales_Order_View
{
public function __construct() {
parent::__construct();
$order = $this->getOrder();
$this->_addButton('inform_pickup', array(
'label' => Mage::helper('sales')->__('Custom Pickup Button'),
'onclick' => 'setLocation(\'' . $this->getPickupUrl($order) . '\')',
));
}
public function getPickupUrl($order)
{
return $this->getUrl('pickup/adminhtml_index/pickup', array('order_id' => $order->getId()));
}
}
?>
The problem is that my
return $this->getUrl('pickup/adminhtml_index/pickup', array('order_id' => $order->getId()));
is not working. It redirects me to a front page 404. What am I doing wrong in this Url?
UPDATE
Added /app/code/local/Mymodule/Pickup/etc/adminhtml.xml
<?xml version="1.0"?>
<config>
<acl>
<resources>
<admin>
<children>
<system>
<children>
<config>
<children>
<pickup translate="title" module="pickup">
<title>Pickup</title>
<sort_order>100</sort_order>
</pickup>
</children>
</config>
</children>
</system>
</children>
</admin>
</resources>
</acl>
</config>
Best Answer
There are lot of issue in module.
Controller name should follow magento pattern.
Mymodule_Pickup_IndexController
should beMymodule_Pickup_AdminhtmlIndexController
Rules:
If The controller location is
app/code/MOudleCodePool(local/Community/Core)/[YOurModuleNameSpace]/[YourModuleName]/controllers/RestofPathTillControllerFile/[ControllerName]Controller.php
Then class
[YOurModuleNameSpace]_[YourModuleName]_[RestOfPathofControllerTillControllerfolder]_ControllerName{Controller}
But for magento security purpose ,you need use magento rewrite adminhtml controller pattern for add new controller.
see Supee-9788