简体   繁体   中英

How to add a block file i.e., .phtml file to to the sales.xml in magento when the order is viewed from magento admin panel

I want to add a button when an order is viewed from the magento admin panel.Actually i have done by hard-coding in app/design/adminhtml/default/default/sales/order/view/info.phtml file. the button added is got reflected in the admin when the order is viewed. But the thing known to us is the core magento files cannot be modified.

So what i did is i have moved the html code for the button into another mybutton.phtml file and i wanted to display before the app/design/adminhtml/default/default/sales/order/view/info.phtml in the sales.xml file in the < adminhtml_sales_order_view > tag. I have done this in local.xml (my own file) file using < reference > tag where the layout customization are done. But after doing this i got a warning

Invalid argument supplied for foreach() in app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Info.phtml.

Please give me a solution that helps me a lot.

raghav, You need to override the mage block app/code/core/Mage/Adminhtml/Block/Sales/Order/View.php Add the following code to the constructor

    $this->_addButton('order_reorder', array(
        'label'     => Mage::helper('sales')->__('My Button'),
        'onclick'   => 'setLocation(\'' . $this->getUrl('path/of/url') . '\')',
    )); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM