Site icon Silva Tech Solutions LLC

Custom Magento Admin Order Buttons Fix on Upgrade

After upgrade to EE1.12 or greater, some adminhtml custom buttons that were created for Orders, did not work. Magento changed the way the code was structured, and refactored a ton of their code.

Our button code used to resolve in the local/Mage/Adminhtml/Block/Sales/Order/Grid.php.
Magento moved it to the “View.php” (more logical in our opinion).
To fix your buttons, grab a fresh copy of the core file (Mage/Adminhtml/Block/Sales/Order/View.php) to your local folder.
Add your button creation code to to the local/Mage/Adminhtml/Block/Sales/Order/View.php

//Example
...
 
$this->_addButton('custompdfinvoices_order', array(
'label' => Mage::helper('sales')->__('Store Invoice'),
'onclick' => 'setLocation(\'' . $this->getUrl('*/sales_invoice/custompdfinvoices') . '\')',
'class' => 'go'
));

//Example

$this->_addButton(‘custompdfinvoices_order’, array(
‘label’ => Mage::helper(‘sales’)->__(‘Store Invoice’),
‘onclick’ => ‘setLocation(\” . $this->getUrl(‘*/sales_invoice/custompdfinvoices’) . ‘\’)’,
‘class’ => ‘go’
));

Since the buttons now are now just using a jquery link (ig: GET action), make sure your controller (ig: /local/Mage/Adminhtml/Controller/Sales/Invoice.php is set to use a “GET” request (getParam) instead of a “getPost”.

Exit mobile version