Book Image

Magento 2 Development Cookbook

Book Image

Magento 2 Development Cookbook

Overview of this book

With the challenges of growing an online business, Magento 2 is an open source e-commerce platform with innumerable functionalities that gives you the freedom to make on-the-fly decisions. It allows you to customize multiple levels of security permissions and enhance the look and feel of your website, and thus gives you a personalized experience in promoting your business.
Table of Contents (18 chapters)
Magento 2 Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Registering a backend controller


The first thing that we will learn is how to extend the backend with a custom controller action. We need a controller that is secured so that only logged-in backend users can see the contents of this page.

A backend controller is required when you want to add an extra page to the backend of Magento. This is mostly the case when you are working with a custom form or overview that you need for your module.

Getting ready

For development purposes, it is recommended that we remove the secret key (the hash in the URL) from the admin URLs. You can configure this in Stores | Configuration | Advanced | Admin | Security. Change the configuration as shown in the following screenshot:

How to do it...

When you want to add an extra page to your backend, you have to follow these steps:

  1. Create the file routes.xml in the folder app/code/Packt/HelloWorld/etc/adminhtml with the following content:

    <?xml version="1.0"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance...