× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

Make sure your Magento Admin Controller name is unique

Geoff Douglas
Mar 11, 2016
<p>When you create &amp; register an adminhtml controller in Magento, your custom module namespace and module name gets lost, when the adminhtml controllers are collected. So, we must remember to make our custom admin controller names unique.</p> <p>Since Magento or rather the Security Patch <span style="background-color:rgb(255, 255, 255); color:rgb(95, 99, 102)">SUPEE-6788, they have discontinued the use of using just any path as a secure admin path, and know we need to register all adminhtml controllers in to the admin router.</span></p> <p> </p> <pre><code class="language-xml">&lt;!-- namespace_modulename = our namespace and modulename this key just needs to be unique in the list of admin controllers Namespace_Module_Adminhtml = our admin controller class prefix --&gt; &lt;admin&gt; &lt;routers&gt; &lt;adminhtml&gt; &lt;args&gt; &lt;modules&gt; &lt;namespace_modulename before="Mage_Adminhtml"&gt; Namespace_Module_Adminhtml &lt;/namespace_modulename&gt; &lt;/modules&gt; &lt;/args&gt; &lt;/adminhtml&gt; &lt;/routers&gt; &lt;/admin&gt;</code></pre> <pre><code class="language-php">// Remember we registered Namespace_Module_Adminhtml as our prefix class Namespace_Module_Adminhtml_UniquenameController extends Mage_Adminhtml_Controller_Action { /** * New action */ public function newAction() { } }</code></pre> <pre><code class="language-php">/** * * In our adminhtml blocks, for grids and forms and such, we use just * the unique name. The * representing the configured admin url key. * */ $this-&gt;getUrl('*/uniquename/new');</code></pre> <p> </p>
comments powered by Disqus