magento 添加custom tabs

有时候项目的需要,我们可能会在后台中添加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在里面添加一下代码:


    
    
        
            
        
    
    

block的创建inventoryinfo/adminhtml_inventoryinfo

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

你可能感兴趣的:(php,magento)