Categories


Archives


Recent Posts


Categories


Creating Magento 2 Admin Routes with Pestle

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!

If you grab the latest version of pestle (updated minutes ago) you should be able to use the following set of commands to create a base module with a working admin route.

$ pestle.phar generate_module Pulsestorm HelloAdminPestle2 0.0.1

$ php bin/magento module:enable Pulsestorm_HelloAdminPestle2

$ php bin/magento setup:upgrade

$ pestle.phar generate_route Pulsestorm_HelloAdminPestle2 adminhtml pulsestorm_hello_admin_pestle2

$ pestle.phar generate_acl Pulsestorm_HelloAdminPestle2 Pulsestorm_HelloAdminPestle2::top,Pulsestorm_HelloAdminPestle2::menu_1

$ pestle.phar generate_menu Pulsestorm_HelloAdminPestle2 Magento_Backend::system_other_settings Pulsestorm_HelloAdminPestle2::a_menu_item Pulsestorm_HelloAdminPestle2::menu_1 "Hello Admin Pestle" pulsestorm_hello_admin_pestle2/index/index 1

$ pestle.phar generate_view Pulsestorm_HelloAdminPestle2 adminhtml pulsestorm_hello_admin_pestle2_index_index Main content.phtml ""

Previous versions of pestle could get you part of the way there, but a few adjustments (no layout="" attribute in adminhtml handle XML files, different admin block base class, removing block input from generate_view) needed to be made for admin generation to work.

If you’re curious about what the above commands are doing,

$ pestle.phar help command_name

Will give you the argument names and (in some cases) help text. A lot is covered in my recent Understanding Access Control List Rules and Admin Menu Items, and my next article will cover creating an route and view files in the admin (generate_route and generate_view above)

Copyright © Alana Storm 1975 – 2023 All Rights Reserved

Originally Posted: 13th May 2016

email hidden; JavaScript is required