Im trying to add a simple button to the Magento Order. I tried the solution from stackoverflow but it is not working. This is my code, would be great if you can tell me what Im doing wrong. Thank you.
app/local/FirstGood/PrintCard/Block/Adminhtml/Sales/Order/View.php
<?
class FirstGood_PrintCard_Block_Adminhtml_Sales_Order_View extends Mage_Adminhtml_Block_Sales_Order_View {
public function __construct() {
parent::__construct();
$this->addButton('button_id', array(
'label' => Mage::helper('xxx')->__('Some action'),
'onclick' => 'jsfunction(this.id)',
'class' => 'go'
), 0, 100, 'header', 'header');
}
}
app/local/FirstGood/PrintCard/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<FirstGood_PrintCard>
<version>0.0.1</version>
</FirstGood_PrintCard>
</modules>
<global>
<blocks>
<adminhtml>
<rewrite>
<sales_order_view>FirstGood_PrintCard_Block_Adminhtml_Sales_Order_View</sales_order_view>
</rewrite>
<events>
<adminhtml_widget_container_html_before>
<observers>
<firstgood_printcard>
<class>firstgood_printcard/observer</class>
<type>singleton</type>
<method>adminhtmlWidgetContainerHtmlBefore</method>
</firstgood_printcard>
</observers>
</adminhtml_widget_container_html_before>
</events>
</adminhtml>
</blocks>
</global>
</config>
app/local/FirstGood/PrintCard/Model/Observer.php
<?php
class FirstGood_PrintCard_Model_Observer {
public function adminhtmlWidgetContainerHtmlBefore($event)
{
$block = $event->getBlock();
if ($block instanceof Mage_Adminhtml_Block_Sales_Order_View) {
$message = Mage::helper('your_module')->__('Are you sure you want to do this?');
$block->addButton('do_something_crazy', array(
'label' => Mage::helper('your_module')->__('Export Order'),
'onclick' => "confirmSetLocation('{$message}', '{$block->getUrl('*/yourmodule/crazy')}')",
'class' => 'go'
));
}
}
}
app/etc/modules/FirstGood_PrintCard.xml
<?xml version="1.0"?>
<config>
<modules>
<FirstGood_PrintCard>
<active>true</active>
<codePool>local</codePool>
<version>0.1.0</version>
</FirstGood_PrintCard>
</modules>
</config>