4

I have been charged with customizing Magento 1.9.1 and my question seems complicated to me, but might not to a seasoned MageDev.

What I want to do is have an attribute set, say "UniqueChoice", and in our application based on the roles of "Admin" and "Showcase", we would like to have more/less options. What is the best way to accomplish this? Can it somehow be done through the GUI? Or will I need to override some files to add this functionality?

  • This is all possible, but you'll need to customize a template and implement the attributes and permissions. – SR_Magento Feb 9 '15 at 22:17
2

I don't believe you can assign a Role with ACL specific enough to show/hide individual attributes.

However, I think it would be possible by editing the renderer for the adminhtml catalog page.

*Note: This is not the Magento way of doing it. This is just a proof of concept to show that it is possible to do. This code works and hopefully it will inspire you to come up with a proper solution. *

Edit the following file:

app/design/adminhtml/default/default/template/catalog/form/renderer.phtml

Near the top of the file after <?php $_element = $this->getElement() ?>, add this code:

<?php

    // Admin Role that needs special permission
    $admin_role = "Showcase"; 

    // Array with all of the Attributes you want to exclude from your custom Admin Role
    $disallowed_attributes[]="name";
    $disallowed_attributes[]="description";
    $disallowed_attributes[]="short_description";
    // Keep adding these lines.  One for every attribute code that you want your special role to not show.

    $role = Mage::getSingleton('admin/session')->getUser()->getRole()->getRoleName();
    if (in_array($_element->getId(),$disallowed_attributes) && $role==$admin_role) {
        return false;  // Don't display this attribute
    }

?>

One thing to keep in mind is if you exclude an attribute that is a required field then you won't be able to save your product since that required field will not be showing.

I hope this helps get you started on creating a more permanent solution.

1

In Magento 2, it can be done by overriding the template at following path

app/design/adminhtml/XXXX/backend/Magento_Catalog/templates/catalog/form/renderer/fieldset/element.phtml

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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