有时候项目的需要,我们可能会在后台中添加tabs,现在给product edit页面添加一个tabs
图片描述

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

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

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

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

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在里面添加一下代码:


    <!--产品卷号、批次-->
    <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_inventoryinfo

 public function __construct()
    {
        $this->setTemplate();//phtml模板路径
        $this->setUseAjax(true);
    }

Abbott
103 声望8 粉丝

magento二次开发,欢迎交流