8

I created custom module in magento. I created that menu under customer menu. I need to add acl for custom module. I need to know that how to create acl in custom module i m giving here my config.xml...

my config.xml
------------------
<?xml version="1.0" encoding="UTF-8" ?>
<config>
    <!-- module configuration -->
    <modules>
        <Webcreon_Seller>
            <version>1.0.0</version>
        </Webcreon_Seller>
    </modules>
    <!-- module configuration end -->
    <frontend>
        <routers>
            <seller>
                <use>standard</use>
                <args>
                    <module>Webcreon_Seller</module>
                    <frontName>seller</frontName>  
                </args>
            </seller>
        </routers>
     <layout>
            <updates>
                <seller>
                      <file>sellerform.xml</file>
                </seller>
            </updates>
       </layout>
    </frontend>
    <admin>
     <routers>
         <seller>
            <use>admin</use>
            <args>
               <module>Webcreon_Seller</module>
               <frontName>adminseller</frontName>
            </args>
         </seller>
      </routers>
 </admin>
 <adminhtml>
   <layout>
      <updates>
          <seller>
              <file>sellerform.xml</file>
           </seller>
      </updates>
   </layout>
   <menu>
      <customer translate="title" module="adminhtml">

         <sort_order>100</sort_order>
         <children>
             <set_time>
                   <title>Seller List</title>
                   <action>adminseller/adminhtml_index</action>
              </set_time>
          </children>
       </customer>
    </menu>
</adminhtml> 

    <global>
        <blocks>
            <seller>
                <class>Webcreon_Seller_Block</class>
            </seller>
         </blocks>
         <helpers>
            <seller>
                <class>Webcreon_Seller_Helper</class>
            </seller> 
        </helpers>
              <models>
          <seller>
                <class>Webcreon_Seller_Model</class>
                 <resourceModel>seller_mysql4</resourceModel>
            </seller> 
            <seller_mysql4>
             <class>Webcreon_Seller_Model_Mysql4</class>
             <entities>
                 <seller>
                   <table>db_vendor</table>
                 </seller>
              </entities>
          </seller_mysql4>
        </models>
        <resources>
        <!-- connection to write -->
        <seller_write>
            <connection>
                <use>core_write</use>
            </connection>
        </seller_write>
        <!-- connection to read -->
       <seller_read>
          <connection>
             <use>core_read</use>
          </connection>
       </seller_read>
       <webcreon_seller_setup>
            <setup>
                <module>Webcreon_Seller</module>
            </setup>
        </webcreon_seller_setup>
</resources>
<rewrite>
    <sellercreate>
         <from><![CDATA[#^/seller[\/]?$#]]></from>
         <to><![CDATA[/seller/seller/sellercreate/$1]]></to>
         <complete>1</complete>
      </sellercreate>
</rewrite>
</global>


</config>
3

Create adminhtml.xml at Webcreon/Seller/etc where you need put your code

<?xml version="1.0" encoding="UTF-8" ?>
    <config>
        <acl>
          <resources>
            <all>
              <title>Allow Everything</title>
            </all>
            <admin>
             <children>
                <customer translate="title" module="seller">
                  <children>
                    <set_time translate="title">
                    <title>Seller List</title>
                    </set_time>
                  </children>
                </customer>
              </children>
            </admin>
          </resources>
        </acl>
    </config>

Accoring to you have create new menu at customer section a child tab and it name is set_time So i am add this code

    <customer translate="title" module="seller">
      <children>
        <set_time translate="title">
        <title>Seller List</title>
        </set_time>
      </children>
    </customer>
  • i need to show my module in customer acl group..means my in permission under customer section – Deepak Kumar Nov 24 '14 at 6:09
  • yes. it is under at customer – Amit Bera Nov 24 '14 at 6:10
  • its not showing under customers section..also its not showing in acl group – Deepak Kumar Nov 24 '14 at 6:42
  • I created adminhtml in etc...but and your whole code i paste there in file...i deleted cache...then re-login in admin...but in user permission its not showing there – Deepak Kumar Nov 24 '14 at 6:45
  • Make sure to click "Flush Cache Storage" from cache management page. "Flush Magento Cache" does not update it. – Emery King Jun 6 '16 at 15:55
10

A general explanation:

ACL for admin menu

To define the ACL for a custom admin menu entry, copy everything below adminhtml/menu to acl/resources/admin/children and remove the <action> nodes.

Example: What to copy

http://i.stack.imgur.com/9CiIQ.png

To actually use the ACL you have to add the following method to your controller:

protected function _isAllowed()
{
    return Mage::getSingleton('admin/session')->isAllowed('ENTER RESOURCE IDENTIFIER HERE');
}

The resource identifier is base on the node names below acl/resources/admin/children, skipping following children nodes.

Example: Resource identifiers

http://i.stack.imgur.com/HZ2Is.png

ACL for system configuration section

To define the ACL for a system configuration section, the following has to be added below acl/resources/admin/children:

<system>
  <children>
    <config>
      <children>
        <my_configuration_section>
          <title>My Configuration Section</title>
        </my_configuration_section>
      </children>
    </config>
  </children>
</system>

where my_configuration_section is coming from system.xml:

<sections>
    <my_configuration_section translate="label" module="my_module">
      ...
    </my_configuration_section>
</sections>     

Specific to your question:

In your case, that means, adminhtml.xml should look like this:

<?xml version="1.0" encoding="UTF-8" ?>
<config>
    <acl>
      <resources>
        <admin>
         <children>

           <customer translate="title" module="adminhtml">
             <sort_order>100</sort_order>
             <children>
               <set_time>
                 <title>Seller List</title>
               </set_time>
             </children>
           </customer>

          </children>
        </admin>
      </resources>
    </acl>
</config>

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.