4

I recently started working on Magento for one of my projects and stuck at something, which i see a very common use case. I tried looking at different blog post but couldn't find any which can hint towards that.

My question is, I want to able to override the existing frontName for a module in magento. e.g.

If current user dashboard URL is

http://example.com/customer/account/

I want to change it to.

http://example.com/user/account/

Also I will probably add more method in my controller to add few other functionalities. For which I found following post very useful.

https://stackoverflow.com/questions/15212753/getting-2-modules-to-use-same-frontname-in-magento

Can i refer this also any suggestion on how to change frontName?

5

You will need a custom module that only changes the frontname of a module (Mage_Customer in this case.)

Let's name the module Easylife_UserThis module contains only 2 files.

app/etc/module/Easylife_User.xml - the declaration file

<?xml version="1.0"?>
<config>
    <modules>
        <Easylife_User>
            <codePool>local</codePool>
            <active>true</active>
            <depends>
                <Mage_Customer /><!-- should depend on Mage_Customer so it is loaded after it -->
            </depends>
        </Easylife_User>
    </modules>
</config>

app/code/local/Easylife/User/etc/config.xml - the configuration file

<?xml version="1.0"?>
<config>
    <modules>
        <Easylife_User>
            <version>1.0.0</version>
        </Easylife_User>
    </modules>
    <frontend>
        <secure_url>
            <customer>/user/</customer><!-- might be needed if you have secure urls but not sure -->
        </secure_url>
        <routers>
            <customer><!-- for the customer route... -->
                <args>
                    <frontName>user</frontName><!-- just change the front name -->
                </args>
            </customer>
        </routers>
    </frontend>
</config>

Clear the cache and you are done.

If all your links to the customer pages are generated using ->getUrl('customer/...'). This should work.
If you have links in your templates like this

<a href="/customer/...">Customer</a>

It won't work. But anyway, you shouldn't have links like the example above.

  • Thanks @Marius, I am able to change frontName with approach you mentioned. Also, used link mentioned above to create custom controller methods. All Works, Thanks :) – Lalit May 23 '14 at 8:07

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.