Custom controller in Magento admin panel

Magento 2 speed optimization

Custom controller in Magento admin panel, Magento controller has only one execute method that is known as front controller.
For every action, we have one controller class with execute method. Execute method is called when the router matches the controller action class, and it’s responsible for returning a response to the front controller.

Today we clear the URL issue while creating a new controller or working in existing code.
Magento provides a way to define a controller like below-

Route name + controller name + file name.

Check below example for more details –

$url = $this->getUrl('integerbyte_section/customer/newtab', ['_current' => true]);

integerbyte_section is a router name define in the routes.xml file

customer is a folder name like Customer(the first letter is Capital) inside the Controller folder

new tab is a .PHP like Newtab.php file inside the customer folder

File Path app/code/Integerbyte/Section/Controller/Adminhtml/Customer/Newtab.php

Final url : www.example.com/admin/integerbyte_section/customer/newtabkey/da0ef74lkd45sf31d5a31ac8340

The above information to identify admin custom or existing route, Magento 2 custom controller in Magento

Related blogs – Magento Product Types

Source – Magento Guides

Like us on Facebook and Linkedin for more updates.

Back To Top