开发者

How do I add a tab to the Sale Order Admin Page?

开发者 https://www.devze.com 2023-03-28 18:42 出处:网络
I want to add a custom tab to the order page in the admin of magento.Is there a way to do this with a simple overrid开发者_C百科e? Assuming you know how to do a module, here are the steps you need to

I want to add a custom tab to the order page in the admin of magento. Is there a way to do this with a simple overrid开发者_C百科e?


Assuming you know how to do a module, here are the steps you need to perform:

  1. layout update: in your admin's xml layout file you want to "listening" to the admin's order view rendering handle and add your tab:

    <layout>
        <adminhtml_sales_order_view>
            <reference name="sales_order_tabs">
                <action method="addTab"><name>the_name_of_your_tab</name><block>the_block_alias_of_your_module/path_to_your_tab_file</block></action>
            </reference>
        </adminhtml_sales_order_view>
    </layout>
    
  2. the tab file: I generally try to respect Magento's folder structure, so this file would be in app/code/local-or-community/YourNamespace/YourModule/Block/Adminhtml/Order/View/Tab/File.php and will have at least:

    <?php
    class YourNamespace_YourModule_Block_Adminhtml_Order_View_Tab_File
        extends Mage_Adminhtml_Block_Template
        implements Mage_Adminhtml_Block_Widget_Tab_Interface
    {
        protected $_chat = null;
    
        protected function _construct()
        {
            parent::_construct();
            $this->setTemplate('yourmodule/order/view/tab/file.phtml');
        }
    
        public function getTabLabel() {
            return $this->__('Tab label');
        }
    
        public function getTabTitle() {
            return $this->__('Tab title');
        }
    
        public function canShowTab() {
            return true;
        }
    
        public function isHidden() {
            return false;
        }
    
        public function getOrder(){
            return Mage::registry('current_order');
        }
    
  3. The .phtml file, which has to respect the path you specified in the block's __construct(), and should hace something like:

    <div class="entry-edit">
        <div class="entry-edit-head">
            <h4><?php echo $this->__('a title'); ?></h4>
        </div>
        <div class="fieldset fieldset-wide">
            the content you want to show
        </div>
    </div>
    

Hope That Helps

0

精彩评论

暂无评论...
验证码 换一张
取 消