我想将自定义标签添加到销售订单视图表格中。我尝试了以下代码,但是什么都没有发生。 ((链接1, 链接2).

我的布局模块.xml代码是

 <adminhtml_sales_order_view>
        <reference name="sales_order_tabs">
            <action method="addTab"><name>my_tab</name><block>mymodule/Adminhtml_Sales_Order_View_Tabs</block></action>
        </reference>
</adminhtml_sales_order_view>

我的块课是:

class Mymodule_Block_Adminhtml_Sales_Order_View_Tabs  extends Mage_Adminhtml_Block_Sales_Order_Abstract
    implements Mage_Adminhtml_Block_Widget_Tab_Interface
{

    protected function _construct()
    {
        Mage::Log("Fraud created");
    }

    /**
     * Retrieve order model instance
     *
     * @return Mage_Sales_Model_Order
     */
    public function getOrder()
    {
        return Mage::registry('current_order');
    }

    /**
     * Retrieve source model instance
     *
     * @return Mage_Sales_Model_Order
     */
    public function getSource()
    {
        return $this->getOrder();
    }


    public function getTabLabel()
    {
        return Mage::helper('sales')->__('Fraud Detection');
    }

    public function getTabTitle()
    {
        return Mage::helper('sales')->__('Fraud Detection');
    }

    public function canShowTab()
    {
        return true;
    }

    public function isHidden()
    {
        return false;
    }
}

上述代码中有任何错误吗?提前致谢

有帮助吗?

解决方案

尝试

创造: app/code/local/MagePal/OrderFraudDetectionTab/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <MagePal_OrderFraudDetectionTab>
            <version>1.0.1</version>
        </MagePal_OrderFraudDetectionTab>
    </modules>
    <global>
        <blocks>
            <orderfrauddetectiontab>
                <class>MagePal_OrderFraudDetectionTab_Block</class>
            </orderfrauddetectiontab>
        </blocks>
    </global>       
    <adminhtml>
       <layout>
            <updates>
                <orderfrauddetectiontab>
                    <file>magpal_orderfrauddetectiontab.xml</file>
                </orderfrauddetectiontab>
            </updates>
        </layout>
    </adminhtml>
</config>

创造: app/code/local/MagePal/OrderFraudDetectionTab/Block/Adminhtml/Order/View/Tab/FraudDetection.php

<?php
class MagePal_OrderFraudDetectionTab_Block_Adminhtml_Order_View_Tab_FraudDetection
    extends Mage_Adminhtml_Block_Template
    implements Mage_Adminhtml_Block_Widget_Tab_Interface
{    
    //change _constuct to _construct()
    public function _construct()
    {
        parent::_construct();
        $this->setTemplate('magpal/orderfrauddetectiontab/order/view/tab/frauddetection.phtml');
    }

    public function getTabLabel() {
        return $this->__('Fraud Detection');
    }

    public function getTabTitle() {
        return $this->__('Fraud Detection');
    }

    public function canShowTab() {
        return true;
    }

    public function isHidden() {
        return false;
    }

    public function getOrder(){
        return Mage::registry('current_order');
    }
} 
?>

创造: app/design/adminhtml/default/default/template/magpal/orderfrauddetectiontab/order/view/tab/frauddetection.phtml

<?php echo 'add your html/php code here'; ?>

创造: app/design/adminhtml/default/default/layout/magpal_orderfrauddetectiontab.xml

<?xml version="1.0"?>
<layout>
    <adminhtml_sales_order_view>
        <reference name="sales_order_tabs">
            <action method="addTab">
                <name>order_view_tab_orderfrauddetectiontab</name>
                 <block>orderfrauddetectiontab/adminhtml_order_view_tab_frauddetection</block>
            </action>
        </reference>
</adminhtml_sales_order_view>
</layout>

创造: app/etc/modules/MagePal_OrderFraudDetectionTab.xml

<?xml version="1.0"?>
<config>
     <modules>
        <MagePal_OrderFraudDetectionTab>
            <active>true</active>
            <codePool>local</codePool>
        </MagePal_OrderFraudDetectionTab>
    </modules>
</config>
许可以下: CC-BY-SA归因
scroll top