2

I am trying to create a custom controller in admin side.

My config file as below:

<admin>
        <routers>
            <salesref>
                <use>admin</use>
                <args>
                    <module>Ucs_Order</module>
                    <frontName>salesref</frontName>
                </args>
            </salesref>
        </routers>
    </admin>

My Controller located in below:

app\code\local\Ucs\Order\controllers\Adminhtml\ReferenceController.php

Content of my controller as below,

<?php

class Ucs_Order_Adminhtml_ReferenceController extends Mage_Adminhtml_Controller_Action
{

    public function indexAction()
    {
        echo 'Test';
        die;

    }
}

Then I am trying to access the URL as below,

http://192.168.100.68/magento/index.php/salesref/adminhtml_reference/index

But It automatically redirects to dashboard,

Whats the problem with my code?

3
  • Have applied SUPEE-6788 security patch on your Magento? Feb 20, 2016 at 7:26
  • @JayeshPatel No. All other extension I used is redirecting properly
    – Anto S
    Feb 20, 2016 at 7:27
  • Please try to disabled Add Secret Key to URLs setting to No in Admin > System > Configuration > Advanced > Admin > Security (tab). Feb 20, 2016 at 7:43

2 Answers 2

7

If you had secrete settings enabled for Admin URl, it will redirect you to dashboard when you try to run URL without it.

Check settings in admin

Admin -> System -> Configuration -> Advanced (Bottom Left) -> Admin -> Security(Tab) -> Check Field  "Add Secret Key to URLs"

If you want to access URL without secret key try to set value No and check.

4
  • Cheers man.. Problem solved. How can I generate a key for my custom URL?
    – Anto S
    Feb 20, 2016 at 7:44
  • 1
    call URL as Mage::helper("adminhtml")->getUrl("salesref/reference/index"); and you will get it with key itself Feb 20, 2016 at 7:48
  • no it will generate URL for backend Feb 20, 2016 at 7:55
  • Got it.. Did a silly mistake
    – Anto S
    Feb 20, 2016 at 7:56
0

It's not an answer on your question. Just recommendation.

Magento policy do not recommend to use

<use>admin</use>

when you'd like to create admin controller. Look how it achieved in Mage_ImportExport.

If you search throw your app/code folder and find more than 1 it's usage of <use>admin</use> - it's abnormal

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.