Override/Extend routes in existing modules Magento 2
We will learn how to override/extend routes in the existing module.
We can add the before or after parameters in the module node of the routes.xml file.
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="standard">
<route id="catalog">
<module name="Webkul_CustomCatalog" before="Magento_Catalog" />
</route>
</router>
</config>
According to these configurations, FrontController looks for the actions in the Webkul_CustomCatalog before searching in the Magento_Catalog module.
Using the after the tag above ensures Magento checks the Webkul_CustomCatalog module after the Magento_Catalog module.
So with this configuration of routes.xml, we can use the catalog route for the Webkul_CustomCatalog module as well.
Hope it will help you. Thank You.
Tags:
Magento2
View Comments
Comment or Ask a Question
Quick Links