2

I am using Custom Tab code "\Phpcmsframework\Customtabs". Followed link is Custom Tabs.

Expected Result : It shows Custom Tab only while adding product details. Here in image Pickup/Dispatch Address show only on this page.
enter image description here

Current Result : It showing Custom Tab in Previous section ie. Product Type section.Showing Pickup/Dispatch Address Tab in both pages.

enter image description here

Here is my Customtabs.xml file.Please refer it.
customtabs.xml

<?xml version="1.0"?>
<layout>
<adminhtml_catalog_product_edit>
    <reference name="product_tabs">
        <action method="addTab">
            <name>my_custom_tab</name>
            <block>customtabs/adminhtml_catalog_product_tab</block>
        </action>
    </reference>
</adminhtml_catalog_product_edit>
<adminhtml_catalog_product_new>
    <reference name="product_tabs">
        <action method="addTab">
            <name>my_custom_tab</name>
            <block>customtabs/adminhtml_catalog_product_tab</block>
        </action>
    </reference>
</adminhtml_catalog_product_new>
</layout>
2
  • YKJ this Fighpig blog is properly work.it may be your some mistake in code
    – Amit Bera
    Commented Sep 2, 2014 at 6:22
  • show relevant codes Commented Sep 2, 2014 at 6:23

3 Answers 3

2

Just Remove Code from Customtabs.Xml

<adminhtml_catalog_product_new> <reference name="product_tabs"> <action method="addTab"> <name>my_custom_tab</name> <block>customtabs/adminhtml_catalog_product_tab</block> </action> </reference> </adminhtml_catalog_product_new>

Override Block Tabs.php Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs added code

$urlparm = $this->getRequest()->getParam('set', null);
    if(isset($urlparm)){
     $this->addTab('customtab', array(
                'label'     => Mage::helper('catalog')->__('My Custom Tab'),
                'content'   => $this->_translateHtml($this->getLayout()
                    ->createBlock('customtabs/adminhtml_catalog_product_tab')->toHtml()),
            ));
        }
0

Just remove

<adminhtml_catalog_product_new>
    <reference name="product_tabs">
        <action method="addTab">
            <name>my_custom_tab</name>
            <block>customtabs/adminhtml_catalog_product_tab</block>
        </action>
    </reference>
</adminhtml_catalog_product_new>

from customtabs.xml

adminhtml_catalog_product_new layout has been used for 1st step of product that means when we have selecting a product type during product creation

1
  • Thanks for reply. Actually right now it doesn't showing tabs from both pages. I want this tab on second page.
    – YKJ
    Commented Sep 2, 2014 at 6:41
0

I assume that your custom tab class extends Mage_Adminhtml_Block_Widget_Form and implements Mage_Adminhtml_Block_Widget_Tab_Interface.
If it doesn't it should.

Then you are obligated to implement the method canShowTab.
Here you can put your code to determine if the tab should be shown.
Something like this:

public function canShowTab() {
    //get the current product instance
    $product = Mage::registry('product');
    //if on edit mode show the tab
    if ($product->getId()){
        return true;
    }
    //if on add mode and the attribute set has not been selected yet don't show the tab
    if (!$product->getAttributeSetId()){
        return false;
    }
    $request = Mage::app()->getRequest();
    //if creating a configurable product and you have selected the configurable attributes, show the tab
    if ($request->getParam('type') == 'configurable'){
        if ($request->getParam('attributes')){
            return true;
        }
    }
    return false;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.