0

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>
  • Have you installed the latest security patch : SUPEE-6788 ? – Prateek Nov 5 '15 at 9:08
  • Yes I have, but creating this from new, so not like it worked before – Jacco Nov 5 '15 at 9:16
  • The reason Prateek is asking the question is that the patch disables the use of custom admin url's, you should be basing your requests off the admin router blog.husseycoding.co.uk/2015/11/… – Jonathan Hussey Nov 5 '15 at 9:19
  • Not sure what the adminhtml.xml is good for. I don't want a admin menu, I just want the button to change my order status. I am guessing the problem might be in the config.xml. Will add it above – Jacco Nov 5 '15 at 10:28
0

There are lot of issue in module.

Controller name should follow magento pattern.

Mymodule_Pickup_IndexController should be Mymodule_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

  • Amit, its SUPEE-6788 . – Prateek Nov 5 '15 at 9:59
0

you are missing Adminhtml in controller file

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

for router add in your config.xml out sdie the <global></global> tag

<admin>
        <routers>
          <pickup>
            <use>admin</use>
            <args>
              <module>Mymodule_Pickup</module>
              <frontName>pickup</frontName>
            </args>
          </pickup>
        </routers>
    </admin>

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.