magento 添加custom tabs

有时候项目的须要,咱们可能会在后台中添加tabs,如今给product edit页面添加一个tabs
图片描述php

方法1:
按照下面的路径找到tabs.php
图片描述html

找到这个类中的方法_prepareLayout()
在下面加入代码:ajax

$this->addTab('inventoryInfo', array(
                    'label'     => Mage::helper('catalog')->__('批次/卷号/存库'),
                    'url'       => $this->getUrl('inventoryinfo/adminhtml_product/inventoryinfo', array('_current' => true)),
                    'class'     => 'ajax',
                ));

新建模块inventoryInfo,建立控制器inventoryinfo/adminhtml_product/inventoryinfothis

class Silk_Inventoryinfo_Adminhtml_ProductController extends Mage_Adminhtml_Controller_Action
{
    public function inventoryInfoAction()
    {
        $this->loadLayout();
        $block = $this->getLayout()->getBlock('admin.product.inventory');
        $block ->setProductId($this->getRequest()->getParam('id'));
        $this->renderLayout();
    }
}

找到后台的catalog.xml在里面添加一下代码:url

<!--产品卷号、批次-->
    <inventoryinfo_adminhtml_product_inventoryinfo>
        <block type="core/text_list" name="root" output="toHtml">
            <block type="inventoryinfo/adminhtml_inventoryinfo" name="admin.product.inventory" />
        </block>
    </inventoryinfo_adminhtml_product_inventoryinfo>
    <!--产品卷号、批次-->

block的建立inventoryinfo/adminhtml_inventoryinfospa

public function __construct()
    {
        $this->setTemplate();//phtml模板路径
        $this->setUseAjax(true);
    }
相关文章
相关标签/搜索