1

I want to give permission to admin user for a custom module, before creating a acl.xml the module name was not coming in list, after acl.xml its coming but admin user is not able to see in his menu.

Here is acl.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
    <acl>
        <resources>
            <resource id="Magento_Backend::admin">
                <resource id="Magento_Catalog::catalog" title="Products" sortOrder="30">
                    <resource id="Magento_Catalog::catalog_inventory" title="Inventory" sortOrder="10">
                        <resource id="Sup_Brand::shopbybrand" title="ShopByBrand" sortOrder="10" />
                    </resource>
                </resource>
            </resource>
        </resources>
    </acl>
</config>

Here's the menu.xml

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2015 PinkBlue. All rights reserved.
 */
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../app/code/Magento/Backend/etc/menu.xsd">
    <menu>
        <add id="sup_brand::shopbybrand" title="ShopByBrand" module="Sup_Brand" sortOrder="21" parent="Magento_Catalog::inventory" resource="Sup_Brand::sample" action="sup_brand/items/"/>

    </menu>
</config>
1

2 Answers 2

2

change in your acl.xml with this line

<resource id="Sup_Brand::sample" title="ShopByBrand" sortOrder="10" />

and also in your adminhtml controller, in your case it must be PATH_TO_YOUR_ADMIN_CONTROLLER/Items/Index add this function

protected function _isAllowed()
{
  return $this->_authorization->isAllowed('Sup_Brand::sample');
}
3

Your menu resource should match your acl resource.

So in your case you need to replace:

<resource id="Sup_Brand::shopbybrand" title="ShopByBrand" sortOrder="10" />

With:

<resource id="Sup_Brand::sample" title="ShopByBrand" sortOrder="10" />

in your acl.xml

2
  • For privacy i have edited the name of module now updated plz check Commented Oct 24, 2016 at 7:39
  • @supriyamishra see my updated answer Commented Oct 24, 2016 at 7:40

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.