If you want to show only some tab of product edit section in admin of magento then check below details.. In the product edit section (Admin => System => Catalog => Manage products => Edit) I wan to display only the General tab for a particular product type.It can also be set for perticualr users also.Now I am showing you the trick only for product type that is for simple product and for all other product all the tab will be shown as it is.

For how to display only the general tab in admin product edit section I have created a simple custom module called JRB_Hideproducttabs and done all processing through observer.In this module the main coding part I have placed in config.xml file and another is observer.php file.

In config.xml file I have declared the observer location and class method in which all process will be done.The config.xml file is placed at the dir: app/code/local/JRB/Hideproducttabs/etc and same way the Observer.php is place at dir:app/code/local/JRB/Hideproducttabs/Model

So now check the below coding for observer declaration :

< ?xml version="1.0"?>

  
    
      0.1.0
    
  
  
	
	  
		JRB_Hideproducttabs_Model
	  
	
    
	   
        
           
            model 
            hideproducttabs/observer 
            hideTabs  
             
          
        
      
    
  
  
	
		
			
				hideproducttabs.xml
			
		
	
  

Also apart from observer I can hide some tab through layout xml file that I have declared in adminhtml section of config.xml file.The hidproducttabs.xml file is situeted at dir:app/design/adminhtml/default/default/layout

< ?xml version="1.0"?>

    
        
			related
			categories
			....................
			....................
		
    

Finally the check codings for Observer.php and is located at dir: app/code/local/JRB/Hideproducttabs/Model

< ?php
class JRB_Hideproducttabs_Model_Observer
{
    public function hideTabs(Varien_Event_Observer $observer)
    {
        $action = Mage::app()->getFrontController()->getAction();
        $acionName = $action->getFullActionName();
        if($acionName === 'adminhtml_catalog_product_edit'){
            //Mage::dispatchEvent('admin_session_user_login_success', array('user'=>$user));
            //$user = $observer->getEvent()->getUser();
            $event = $observer->getEvent();
            $tabBlock = $event->getBlock();
            if ($tabBlock instanceof Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs) {
                try{
                    $product = $tabBlock->getProduct();
                    $productType = $product->getTypeID();
                    if($productType == 'simple'){
                        if (!($setId = $product->getAttributeSetId())) {
                            $setId = $this->getRequest()->getParam('set', null);
                        }
                        if ($setId) {
                            $groupCollection = Mage::getResourceModel('eav/entity_attribute_group_collection')
                                ->setAttributeSetFilter($setId)
                                ->setSortOrder()
                                ->load();
                            foreach ($groupCollection as $group) {
                                $label = Mage::helper('catalog')->__($group->getAttributeGroupName());
                                if($label == 'General'){
                                    $generalId = 'group_'.$group->getAttributeGroupId();
                                }
                            }
                        }
                        $tab_ids = $tabBlock->getTabsIds();
                        $tabs_to_show = array($generalId);
                        foreach ($tab_ids as $tab){
                            if(!in_array($tab, $tabs_to_show)){
                                $tabBlock->removeTab($tab);
                            }
                        }
                    }
                }catch(Exception $e){
                    Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
                }
            }
        }
    }
}
how to display only the general tab in admin product edit section
Tagged on:                             

Leave a Reply

Your email address will not be published. Required fields are marked *