Magento – Magento 2 how to extend core module

controllersextendmagento2

I want to add a button to abc.com/customer/account page when the user click it, it will redirect to a new page e.g. customer/account/upgrademember. How can I do this? I find it difficult to route it to my module. In Magento_Customer module, the \Magento\Customer\etc\frontend\route.xml defines when the frontName is customer, Magento will go to Magento_Customer module. But I create a new Controller upgrademember.php in my module. How can the Magento go to my upgrademember.php when the user clicks the abc.com/ccustomer/account/upgrademember.?

Best Answer

Finally, I got another solution. It is adding routes.xml under etc/frontend

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
   <router id="standard">
        <route id="customer" frontName="customer">
            <module name="Namespace_ModuleName" />
        </route>
    </router>
</config>

It will redirect the upgrade abc.com/ccustomer/account/upgrademember to the my custom module's controller UpgradeMember.php

Related Topic