1

I need a blank page to receive a post of ajax and return json.

If I run the code below any page of backend, the link opens a blank page, that set up on my controller and router.

<?php echo Mage::helper('adminhtml')->getUrl('installments/adminhtml_ajax/'); ?>

But if I run into any page of the frontend, the key of the url is not the same and I am directed to the dashboard.

I do not know how to get the correct URL for the frontend, someone would have an idea that works?

Examples:

Backend  = installments/adminhtml_ajax/index/key/000085c50c4882df8a9cae52c8392227/
Frontend = installments/adminhtml_ajax/index/key/99edadac5bc5bb1e2421d3be38db525e/

Routers

<frontend>
    <routers>
        <installments>
            <use>admin</use>
            <args>
                <module>Dexxtz_Installments</module>
                <frontName>installments</frontName>
            </args>
        </installments>         
    </routers>
</frontend>
<admin>
    <routers>
        <installments>
            <use>admin</use>
            <args>
                <module>Dexxtz_Installments</module>
                <frontName>installments</frontName>
            </args>
        </installments>
    </routers>
</admin>

Already changed the frontend for standard and nothing has changed.

  • Can you add your config.xml to your question? – Renon Stewart Dec 17 '14 at 20:42
  • Added routers @R.S – Dexxtz Dec 18 '14 at 10:23
2

The key in the url is generated based on the admin session.
And you cannot share the admin and frontend sessions, that's why when making the call from the frontend you get a different session key.

Anyway, it's not a good practice to make calls to backend actions from the frontend.
You should have 2 separate controllers, one for backend and one for frontend.
In order not to duplicate the code, you can put everything inside a method in a helper and just call that method in both controllers.

2

Your front and admin <routers> (<frontName>installments</frontName>) should not be the same.

They are two ways to configure admin modules

1) Given it a different front name

  <admin>
    <routers>
        <installments>
            <use>admin</use>
            <args>
                <module>Dexxtz_Installments</module>
                <frontName>admin_installments</frontName>

2) Put your module before/after adminhtml

<admin>
      <routers>
        <adminhtml>
            <args>
                <modules>
                    <Company_Adminhtml before="Mage_Adminhtml">Company_Adminhtml</Company_Adminhtml>

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.