12

I created a module, and it works perfectly; however, I hit a wall. When I'm logged in as admin, everthing is good. I added this in the acl:

<?xml version="1.0"?>
<config>
    <menu>
        <erp translate="title" module="firtal_deadstock">
            <title>ERP</title>
            <sort_order>99</sort_order>
            <children>
                <stock_management module="firtal_deadstock">
                                <title>Stock Management</title>
                                <children>
                                    <firtal_deadstock>
                                        <title><![CDATA[Firtal Stock Analysis]]></title>
                                        <sort_order>99</sort_order>
                                        <action>adminhtml/deadstock</action>
                                    </firtal_deadstock>
                                </children>
                </stock_management>
            </children>
        </erp>
    </menu>
    <acl>
        <resources> 
            <all>
                <title>Allow Everything</title>
            </all>
            <admin>
                <children>
                    <system>
                        <children>
                            <config>
                                <children>
                                    <firtal_deadstock translate="title">
                                        <title>Firtal Stock Analysis settings</title>
                                        <sort_order>100</sort_order>
                                    </firtal_deadstock>
                                </children>
                            </config>
                        </children>
                    </system>
                    <erp module="firtal_deadstock">
                        <children>
                            <stock_management module="firtal_deadstock">
                                <children>
                                    <firtal_deadstock translate="title" module="firtal_deadstock">
                                        <title>Firtal Stock Analysis</title>
                                    </firtal_deadstock>
                                </children>
                            </stock_management>
                        </children>
                    </erp>
                </children>
            </admin>
        </resources>
    </acl>
</config>  

But if I grant the permission to a role and login as a user with that role, they do see the menu point (not the config, but the actual menu point), but if I press it, I get an Access Denied error:

enter image description here

What am I missing?

1 Answer 1

24

I have a hunch you have in your admin controller a method called _isAllowed.
If that's true, I think it returns the wrong thing.
It should look like this:

protected function _isAllowed()
{
    return Mage::getSingleton('admin/session')->isAllowed('erp/stock_management/firtal_deadstock');  
    //or at least
    //return Mage::getSingleton('admin/session')->isAllowed('erp/stock_management');  

}
3
  • DUH! That was it. I actually tried to add a _isAllowed(), but that gave me a 503. I was working on a live server, so I couldn't see the exception data. Obviously it was because I was redeclaring it as I forgot I declared it in the middle of the class. Thanks a bunch, have a great weekend!
    – Dencker
    Commented Jul 18, 2014 at 12:07
  • or you can also write : protected function _isAllowed() { return true; } Commented Sep 14, 2016 at 0:27
  • 2
    But that will make it available for every admin. Even if he should not have access to it.
    – Marius
    Commented Sep 14, 2016 at 5:00

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.