Adding Functionality to an Existing Magento 2 FrontName
Scenario;
You want to add some additional functionality to the customer section and you want it to reside under the customer frontname created by the magento-customer module.
How do you do this?
In app/code/[codePool]/[Vendor]/[ModuleName]/etc/frontend/routes.xml:
<?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">
<module name="[Vendor]_[ModuleName]" after="Magento_Customer" />
</route>
</router>
</config>
There are two important bits.
Firstly, because you are attaching to an existing route, you do not need to specify a frontName attribute.
Secondly, and most importantly you are telling Magento to look at your module after the Magento_Customer one to see if a class can be found for the request.
For another example see the Magento_UrlRewrite module.
Like this post? Share it :)