Reading list Switch to dark mode

    Override/Extend routes in existing modules Magento 2

    Updated 22 February 2024

    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.

    Searching for an experienced
    Magento 2 Company ?
    Find out More
    . . .

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    Be the first to comment.

    Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home