Access denied – Magento module error

I believe that most of you building custom Magento module came across this error “Access denied” when trying to view their module output in Magento administration. I just lost around an hour trying to find my way around this one. Note, this is far from my first Magento module, however it still got me thinking and sweeting. So I thought I’ll share the pain 🙂

Main issue (or super cool feature) with modules is that most of the config.xml errors die peacefully, meaning you see no meaningful error description on page. You either see stuff like “Access denied” or you see blank page or you see god know what.

Anyhow, to keep it short. Here is the screen shot of my simple module (work in progress).

Working Magento module admin system area.

And here is the famous “Access Denied” error.

Magento module access denied

There are few tweaks out there that tell you what you can do to solve this error, like the one on Inchoo site. My college wrote that one 🙂 -Unfortunately it did not do any good in my case.

Here is my faulty example of system.xml

<?xml version="1.0"?>
 
<config>
 
    <tabs>
        <activecodeline translate="label" module="devster">
            <label>ActiveCodeline</label>
            <sort_order>100</sort_order>
        </activecodeline>
    </tabs>
 
    <sections>
    	<activecodeline translate="label" module="devster">
            <label>Devster</label>
            <tab>activecodeline</tab>
            <frontend_type>text</frontend_type>
            <sort_order>910</sort_order>
            <show_in_default>1</show_in_default>
            <show_in_website>1</show_in_website>
            <show_in_store>1</show_in_store>  	
 
            <groups>
                <columns translate="label">
                    <label>Some cool option group here</label>
                    <comment>Oh yea, MAGENTO is so cool that it allows me to add comments under special section named comments</comment>
                    <sort_order>200</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <fields>
                        <default translate="label comment">
                            <label>Some cool custom option</label>
                            <comment>Here is the description of required option value.</comment>
                            <frontend_type>text</frontend_type>
                            <sort_order>1</sort_order>
                            <show_in_default>1</show_in_default>
                        </default>
                    </fields>
                </columns>
                </groups>            
 
    	</activecodeline>
    </sections>
</config>

And here is the working one:

<?xml version="1.0"?>
 
<config>
 
    <tabs>
        <activecodeline translate="label" module="devster">
            <label>ActiveCodeline</label>
            <sort_order>100</sort_order>
        </activecodeline>
    </tabs>
 
    <sections>
    	<devster translate="label" module="devster">
            <label>Devster</label>
            <tab>activecodeline</tab>
            <frontend_type>text</frontend_type>
            <sort_order>910</sort_order>
            <show_in_default>1</show_in_default>
            <show_in_website>1</show_in_website>
            <show_in_store>1</show_in_store>  	
 
            <groups>
                <columns translate="label">
                    <label>Some cool option group here</label>
                    <comment>Oh yea, MAGENTO is so cool that it allows me to add comments under special section named comments</comment>
                    <sort_order>200</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <fields>
                        <default translate="label comment">
                            <label>Some cool custom option</label>
                            <comment>Here is the description of required option value.</comment>
                            <frontend_type>text</frontend_type>
                            <sort_order>1</sort_order>
                            <show_in_default>1</show_in_default>
                        </default>
                    </fields>
                </columns>
                </groups>            
 
    	</devster>
    </sections>
 
</config>

Plus the config.xml file:

<?xml version="1.0"?>
 
<config>
    <modules>
        <ActiveCodeline_Devster>
            <version>0.0.1</version>
        </ActiveCodeline_Devster>
    </modules>
 
	<global>
		<models>
			<devster>
				<class>ActiveCodeline_Devster_Model</class>
			</devster>
	    </models>
 
		 <blocks>
			<devster>
				<class>ActiveCodeline_Devster_Block</class>
			</devster>
		</blocks>   	    
 
		 <helpers>
			<devster>
				<class>ActiveCodeline_Devster_Helper</class>
			</devster>
		</helpers>   
	</global>
 
    <adminhtml>
        <acl>
          <resources>
			<all>
				<title>Allow Everything</title>
			</all>
            <admin>
              <children>
                  <system>
                      <children>
                        <config>
                          <children>
                            <devster>
                              <title>ActiveCodeline Area</title>
                            </devster>
                          </children>
                        </config>
                      </children>
                  </system>
              </children>
            </admin>
          </resources>
        </acl>
    </adminhtml>
 
</config>

If you look carefully to system.xml file, under sections, you will see that section names are the only thing that’s different in those two files, which I accidentally replaced and totally overlooked. Most likely you will get the same error if you accidentally replace any other tag name.

To me personally, xml related errors in Magento (from config files to layout files) are among most irritating of all errors. They give so little error description that one can loose many minutes (hours) trying to find the.

Keep an eye on it.


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <blockquote cite=""> <code> <del datetime=""> <em> <s> <strike> <strong>. You may use following syntax for source code: <pre><code>$current = "Inchoo";</code></pre>.