Hide Attributes and Other Fields in Product Edit Backend
Set is_visible
to 0
on the attribute and it won't show up in admin forms (product page and also the attribute management page).
You can do it via a SQL tool or programmatically in a setup script:
$installer->updateAttribute('catalog_product', $attribute_code, 'is_visible', '0');
This is possible with observing the events core_block_abstract_prepare_layout_before
(method removeAttributes()
) and core_block_abstract_prepare_layout_after
(method removeTabs()
).
remark: I am putting this into a module which adds ACL entries for each attribute / tab so they can be hidden from certain users.
In the observers we have to check, that we are in the block Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs
and can remove tabs or attributes.
/**
* Overwrite the cache field in the product to remove disabled attributes
*
* event: core_block_abstract_prepare_layout_before
*
* @param Varien_Event_Observer $event
*/
public function removeAttributes(Varien_Event_Observer $event)
{
$block = $event->getBlock();
if (!$block instanceof Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs) {
return;
}
$editableAttributes = $block->getProduct()->getTypeInstance()->getEditableAttributes();
$adminSession = Mage::getSingleton('admin/session');
// TODO: remove attribute to hide from the $editableAttributes array
$block->getProduct()->setData('_cache_editable_attributes', $editableAttributes);
}
/**
* Remove hidden tabs from product edit
* event: core_block_abstract_prepare_layout_after
*
* @param Varien_Event_Observer $event
*/
public function removeTabs(Varien_Event_Observer $event)
{
$block = $event->getBlock();
if (!$block instanceof Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs) {
return;
}
// TODO / Example: remove inventory tab
$block->removeTab('inventory');
// fix tab selection, as we might have removed the active tab
$tabs = $block->getTabsIds();
if (count($tabs) == 0) {
$block->setActiveTab(null);
} else {
$block->setActiveTab($tabs[0]);
}
}