Categories


Archives


Recent Posts


Categories


Notes on Magento 2 Routing

astorm

Frustrated by Magento? Then you’ll love Commerce Bug, the must have debugging extension for anyone using Magento. Whether you’re just starting out or you’re a seasoned pro, Commerce Bug will save you and your team hours everyday. Grab a copy and start working with Magento instead of against it.

Updated for Magento 2! No Frills Magento Layout is the only Magento front end book you'll ever need. Get your copy today!

Not a comprehensive guide, and as always, let the core module’s be your guide.

  1. Router configuration has been moved from config.xml to etc/frontend/routes.xml and etc/backend/routes.xml

  2. There’s still a routerName/frontName distinction, although the router’s name is specified with an id attribute instead of the node name in routes.xml (which makes it a router id)

  3. If you want your module to have controllers you’ll need to work with PHP namespaces, as MagentoCoreAppRouterBase::getControllerClassName returns a controller classname using namespaces.

  4. The controller name is in the form PackagenameModulenameController[Controller Name]. No more controllers folders!

  5. No more controlers folder because the above autoloads from app/code/Packagename/Modulename/Controller/Controllername.php

  6. Base controllers are MagentoCoreControllerFrontAction and MagentoBackendControllerAdminhtmlAction for the frontend and backend. There’s a MagentoCoreControllerVarienAction still lurking around the codebase — don’t use this for your controllers.

Copyright © Alana Storm 1975 – 2023 All Rights Reserved

Originally Posted: 12th November 2013

email hidden; JavaScript is required