2

Currently i have faced one issue. when i call frontend controller from this url project/index.php/become-a-ditributor.html

front controller action call successfully but after success my url show admin_ in url. i dont know what is problem.

config.xml

  <?xml version="1.0"?>
<config>
    <modules>
        <DD_Distributor>
            <version>0.1.0</version>
        </DD_Distributor>
    </modules>
    <frontend>
        <routers>
            <distributor>
                <use>standard</use>
                <args>
                    <module>DD_Distributor</module>
                    <frontName>distributor</frontName>
                </args>
            </distributor>
        </routers>
        <layout>
            <updates>
                <distributor>
                    <file>distributor.xml</file>
                </distributor>
            </updates>
        </layout>
    </frontend>
    <global>
        <helpers>
            <distributor>
                <class>DD_Distributor_Helper</class>
            </distributor>
        </helpers>
        <blocks>
            <distributor>
                <class>DD_Distributor_Block</class>
            </distributor>
        </blocks>
        <models>
            <distributor>
                <class>DD_Distributor_Model</class>
                <resourceModel>distributor_mysql4</resourceModel>
            </distributor>
            <distributor_mysql4>
                <class>DD_Distributor_Model_Mysql4</class>
                <entities>        
                    <distributor>
                        <table>distributor</table>
                    </distributor>
                </entities>
            </distributor_mysql4>
        </models>
        <resources>
            <distributor_setup>
                <setup>
                    <module>DD_Distributor</module>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </distributor_setup>
            <distributor_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </distributor_write>
            <distributor_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </distributor_read>
        </resources>
    </global>
    <admin>
        <routers>
            <distributor>
                <use>admin</use>
                <args>
                    <modules>
                        <DD_Distributor after="Mage_Adminhtml">DD_Distributor_Adminhtml</DD_Distributor>
                    </modules>
                </args>
            </distributor>
        </routers>
    </admin>
    <adminhtml>
        <menu>
            <distributor module="distributor">
                <title>Distributor</title>
                <sort_order>100</sort_order>
                <children>
                    <distributor module="distributor">
                        <title>Manage Distributor</title>
                        <sort_order>0</sort_order>
                        <action>adminhtml/distributor</action>
                    </distributor>
                </children>
            </distributor>
        </menu>
        <acl>
            <resources>
                <all>
                    <title>Allow Everything</title>
                </all>
                <admin>
                    <children>
                        <distributor translate="title" module="distributor">
                            <title>Distributor</title>
                            <sort_order>1000</sort_order>
                            <children>
                                <distributor translate="title">
                                    <title>Manage Distributor</title>
                                    <sort_order>0</sort_order>
                                </distributor>
                            </children>
                        </distributor>
                    </children>
                </admin>
            </resources>
        </acl>
        <layout>
            <updates>
                <distributor>
                    <file>distributor.xml</file>
                </distributor>
            </updates>
        </layout>
    </adminhtml>
</config> 

Layout.xml

<?xml version="1.0"?>
<layout version="0.1.0">
  <adminhtml_distributor_index>
    <reference name="content">
      <block type="distributor/adminhtml_distributor" name="distributor" />
    </reference>
  </adminhtml_distributor_index>
</layout>

enter image description here

Can anyone please help me.

  • what you are giving in redirect url in Controller ? – BornCoder Jan 20 '17 at 10:35
  • $this->_redirect('*/distributor/index/'); – Ajay Patel Jan 20 '17 at 10:55
3

I don't get what is problem here but you should use this as admin router configuration

   <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <DD_Distributor after="Mage_Adminhtml">DD_Distributor_Adminhtml</DD_Distributor>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>

change your action from

<action>admin_distributor/adminhtml_distributor</action>

to

<action>adminhtml/distributor</action>

in xml layout this will be

<adminhtml_distributor_index>

update config.xml

    <?xml version="1.0"?>
<config>
    <modules>
        <DD_Distributor>
            <version>0.1.0</version>
        </DD_Distributor>
    </modules>
    <frontend>
        <routers>
            <distributor>
                <use>standard</use>
                <args>
                    <module>DD_Distributor</module>
                    <frontName>distributor</frontName>
                </args>
            </distributor>
        </routers>
        <layout>
            <updates>
                <distributor>
                    <file>distributor.xml</file>
                </distributor>
            </updates>
        </layout>
    </frontend>
    <global>
        <helpers>
            <distributor>
                <class>DD_Distributor_Helper</class>
            </distributor>
        </helpers>
        <blocks>
            <distributor>
                <class>DD_Distributor_Block</class>
            </distributor>
        </blocks>
        <models>
            <distributor>
                <class>DD_Distributor_Model</class>
                <resourceModel>distributor_mysql4</resourceModel>
            </distributor>
            <distributor_mysql4>
                <class>DD_Distributor_Model_Mysql4</class>
                <entities>        
                    <distributor>
                        <table>distributor</table>
                    </distributor>
                </entities>
            </distributor_mysql4>
        </models>
        <resources>
            <distributor_setup>
                <setup>
                    <module>DD_Distributor</module>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </distributor_setup>
            <distributor_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </distributor_write>
            <distributor_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </distributor_read>
        </resources>
    </global>
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <DD_Distributor after="Mage_Adminhtml">DD_Distributor_Adminhtml</DD_Distributor>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>
    <adminhtml>
        <menu>
            <distributor module="distributor">
                <title>Distributor</title>
                <sort_order>100</sort_order>
                <children>
                    <distributor module="distributor">
                        <title>Manage Distributor</title>
                        <sort_order>0</sort_order>
                        <action>adminhtml/distributor</action>
                    </distributor>
                </children>
            </distributor>
        </menu>
        <acl>
            <resources>
                <all>
                    <title>Allow Everything</title>
                </all>
                <admin>
                    <children>
                        <distributor translate="title" module="distributor">
                            <title>Distributor</title>
                            <sort_order>1000</sort_order>
                            <children>
                                <distributor translate="title">
                                    <title>Manage Distributor</title>
                                    <sort_order>0</sort_order>
                                </distributor>
                            </children>
                        </distributor>
                    </children>
                </admin>
            </resources>
        </acl>
        <layout>
            <updates>
                <distributor>
                    <file>distributor.xml</file>
                </distributor>
            </updates>
        </layout>
    </adminhtml>
</config> 
  • code is work but my backend not work its redirect to 404 – Ajay Patel Jan 20 '17 at 11:03
  • @AjayPatel you have to change all url with adminhtml/controllername/action same go with layout adminhtml_controllername_action – Qaisar Satti Jan 20 '17 at 11:05
  • No. Can you please tell me how do this?? DD_Distributor_Adminhtml_DistributorController my current controller name – Ajay Patel Jan 20 '17 at 11:07
  • @AjayPatel i added the example how to do that – Qaisar Satti Jan 20 '17 at 11:09
  • No luck :( with this. – Ajay Patel Jan 20 '17 at 11:13

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.