10

To make editing of products (and maybe also categories) for the shop owner easier, we would like to hide some unnecessary tabs and fields from some users in the admin backend.

This means: Hiding some attributes, but also tabs like "customer reviews", "cross-selling" etc.

How can this be done?

4 Answers 4

10

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');
6
  • Do you know if empty tabs would disappear automatically? And is there a way to make those attributes temporarily visible for admins? Anyways - this would still be a good starting point for a module making them visible on per user basis.
    – Alex
    May 10, 2013 at 9:39
  • 1
    You could extend this - and put in your own ACLs to determine who could/couldn't edit it May 10, 2013 at 9:42
  • I just realized that there are lots of more things than only attributes :-) Edited the title of my question to make that more clear.
    – Alex
    May 10, 2013 at 10:50
  • I think tabs disappear if they are empty. To show them, just add two observers to show them before the request and hide them after? The best idea I have at the moment. And not failproof when two people are in the shop parallel. Alternative: observer and alter the collection query. but then You'll have far to much I think... May 10, 2013 at 11:07
  • They actually do not disappear - and I am talking about tabs which are not about attributes (cross-sell etc.)
    – Alex
    May 10, 2013 at 11:10
8

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]);
    }
}
9
  • Did you ever get anywhere with the ACL setup module? The trouble I'm having is I have hundreds of attribute sets. How would this apply as now there would be hundreds of 'Groups' Tabs as well. Mar 10, 2016 at 18:07
  • yes it is running in a project of us
    – Alex
    Mar 11, 2016 at 8:18
  • Do you have a GIT? We are just working on the same project. Just seeing different strategies. If not, I'll let you know when I'm done as it should be soon. Mar 11, 2016 at 12:57
  • We just built an extension to allow this. It also uses the full functionality of the Aitoc Permission Module as well. So you get a great combination of both. Apr 5, 2016 at 1:38
  • Oh interesting. I do not like Aitoc though ... do you publish your module? Ours is not yet published, ...
    – Alex
    Apr 5, 2016 at 8:43
0

A relatively easy way to hide tabs is to just create a new Admin user and give access only to the areas the Shop Owner will be using. Will keep things simple for the shop owner while still leaving you or some other developer the ability to make changes.

1
  • Sure - that works for general areas (menu entries and so on), but only for very few tabs in the product edit screen (reviews can be disabled like that). Single attributes can not be disabled.
    – Alex
    May 15, 2013 at 12:09
-1

Free module on Magento connect - untested and a bit old (Magento 1.6)

http://www.magentocommerce.com/magento-connect/product-fields-permission-3864.html

Your Answer

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

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