Magento – Acl problem in the custom module (Access denied)

acladmin-panelmagento-1.9

I created a custom module and i placed the list of subscribers under catalog and configuration under system tab and i added acl for this but the tab subscribers under catalog is not accessible but the configuration can access . my acl code is

<adminhtml>
    <menu>
    <catalog>
        <children>
        <outofstocksubscription translate="title" module="outofstocksubscription">
            <title> Subscribers</title>
            <sort_order>190</sort_order>
            <action>outofstocksubscription/adminhtml_subscriber</action>                
        </outofstocksubscription>

     </children>   
    </catalog>
       </menu>  
    <acl>
        <resources>
        <all>
                <title>Allow Everything</title>
            </all>
            <admin translate="title" module="adminhtml">
                 <children>
                  <catalog>
                   <children>
                    <outofstocksubscription translate="title"  module="outofstocksubscription">
                        <title> Subscribers</title>                                         
                    </outofstocksubscription>

             </children>
             </catalog>
                    <system>
                        <children>
                            <config>
                                <children>
                                    <outofstocksubscription translate="title">
                                        <title>Out of Stock Subscription</title>
                                        <sort_order>200</sort_order>
                                    </outofstocksubscription>
                                </children>
                            </config>
                        </children>
                    </system>
                 </children>
            </admin>    
        </resources>    
    </acl>
</adminhtml>    

please help me.

Best Answer

Assuming you can see the menu item, and thus the ACL is set-up correctly, you need to manually make your controller check the ACL too, by adding the following to your controller:

protected function _isAllowed()
{
    return Mage::getSingleton('admin/session')
        ->isAllowed('catalog/outofstocksubscription');
}

Whilst the menu renderer checks the ACL based on path, by default controllers return false (in previous versions of Magento this defaulted to true). You therefore have to code the check in yourself.

Related Topic