4
我試圖在magento促銷/購物車價格規則中添加自定義選項卡。我需要的是,當我選擇任何規則時,自定義選項卡顯示在「管理優惠券代碼」下方,當我點擊自定義選項卡時,我必須獲取具有保存並保存並繼續編輯按鈕的網格表格。任何人都可以建議我以正確的方式來做到這一點?如何在購物車價格規則內添加自定義選項卡
這就是我要添加新的自定義選項卡下面的「管理優惠券代碼」窗口:
我試圖在magento促銷/購物車價格規則中添加自定義選項卡。我需要的是,當我選擇任何規則時,自定義選項卡顯示在「管理優惠券代碼」下方,當我點擊自定義選項卡時,我必須獲取具有保存並保存並繼續編輯按鈕的網格表格。任何人都可以建議我以正確的方式來做到這一點?如何在購物車價格規則內添加自定義選項卡
這就是我要添加新的自定義選項卡下面的「管理優惠券代碼」窗口:
對於完整的解釋,你可以參考這個http://www.newgenray.com/2015/04/22/creating-custom-tab-on-edit-page-in-an-existing-module-of-magento/
首先,你需要創建一個模塊,你必須定義兩件事情之一是佈局和塊
<config>
<modules>
<Newgenray_Coupon>
<version>0.0.1</version>
</Newgenray_Coupon>
</modules>
<adminhtml>
<layout>
<updates>
<newgenray_coupon>
<file>coupon.xml</file>
</newgenray_coupon>
</updates>
</layout>
</adminhtml>
<global>
<blocks>
<newgenray_coupon>
<class>Newgenray_Coupon_Block</class>
</newgenray_coupon>
</blocks>
</global>
然後在文件app /代碼/本地/ Newgenray /座/ Adminhtml /促銷/報價/編輯/標籤/ Custom.php
class Newgenray_Coupon_Block_Adminhtml_Promo_Quote_Edit_Tab_Custom extends Mage_Adminhtml_Block_Widget_Form
implements Mage_Adminhtml_Block_Widget_Tab_Interface
{
/*public function __construct(){
$this->setTemplate('newgenray_coupon/custom_tab.phtml');
}*/
/**
* Mandatory to override as we are implementing Widget Tab interface
* Return Tab Title
*
* @return string
*/
public function getTabTitle(){
return Mage::helper('salesrule')->__('Custom Tab');
}
/**
* Mandatory to override as we are implementing Widget Tab interface
* Return Tab Label
*
* @return string
*/
public function getTabLabel(){
return Mage::helper('salesrule')->__('Custom Tab');
}
/**
* Mandatory to override as we are implementing Widget Tab interface
* Can show tab in tabs
* Here you can write condition when the tab should we shown or not. Like you see when we create shopping cart rule
* Manage coupon tab doesn't come. If you want that then just make a function and check whether you have information
* in registry or not
*
* @return boolean
*/
public function canShowTab(){
return true;
}
/**
* Mandatory to override as we are implementing Widget Tab interface
* Tab is Hidden
*
* @return boolean
*/
public function isHidden(){
return false;
}
/**
* Defines after which tab this tab should come like you asked you need it below Manage Coupon codes
*
* @return string
*/
public function getAfter(){
return 'coupons_section';
}
public function _prepareForm(){
/* To set the data in the form you need to get the data in registry In my example
* I don't have any registry so I am commenting it. My Form will be blank
*/
//$model = Mage::registry('custom_tab_form_data');
$form = new Varien_Data_Form();
$form->setHtmlIdPrefix('rule_');
$fieldset = $form->addFieldset('custom_fieldset', array(
'legend'=>Mage::helper('salesrule')->__('Your Custom Field Set ')
));
$fieldset->addField('name', 'text', array(
'label' => Mage::helper('salesrule')->__('Name'),
'class' => 'required-entry',
'required' => true,
'name' => 'name',
'note' => Mage::helper('salesrule')->__('The name of the example.'),
));
$fieldset->addField('description', 'text', array(
'label' => Mage::helper('salesrule')->__('Description'),
'class' => 'required-entry',
'required' => true,
'name' => 'description',
));
$fieldset->addField('other', 'text', array(
'label' => Mage::helper('salesrule')->__('Other'),
'class' => 'required-entry',
'required' => true,
'name' => 'other',
));
//$form->setValues($model->getData());
$this->setForm($form);
return parent::_prepareForm();
}
}
然後在文件app /應用/設計/ adminhtml /默認/缺省/佈局/coupon.xml
<?xml version="1.0"?>
<layout version="0.1.0">
<adminhtml_promo_quote_edit>
<reference name="promo_quote_edit_tabs">
<action method="addTab">
<name>promo_quote_edit_tab_custom</name>
<block>newgenray_coupon/adminhtml_promo_quote_edit_tab_custom</block>
</action>
</reference>
</adminhtml_promo_quote_edit>
</layout>
最後一步將被激活,我們剛剛創建
<?xml version="1.0"?>
<config>
<modules>
<Newgenray_Coupon>
<active>true</active>
<codePool>local</codePool>
</Newgenray_Coupon>
</modules>
</config>
你回答將幫助模塊,但直到鏈接的作品 –
@DushyantJoshi我已經編輯了答案。 – Pankaj
所以+1 :) –