Skip to content

Admin Basics

  • Controllers all extend Magento\Backend\App\Action (which extends Magento\Framework\App\Action\Action)
    • This provides secret key processing and ACLs
  • Grids are UiComponents
  • Forms also use UiComponents
  • Stores Config exists to save configuration and can be set at any scope
  • Developer level config should be in XML

Routing

etc/adminhtml/menu.xml

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
config/
    menu/
        add/
            @id - unique, convention is VendorName_Module::description
            @title - text to be shown
            @module - VenorName_Module
            @sortOrder - numeric sorting, lower numbers come first
            @parent - the @id of another menu item
            @action - vendor_module/action
            @resource - for ACLs

ACLs

etc/acl.xml

1
2
3
4
5
6
config/
    acl/
        resources/
            resource/ - multiple nested elements for hierarchy
                @id - convention is VendorName_Module::description
                @title

System Configuration

etc/adminhtml/system.xml

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
config/
    system/
        tab/
            @id
            @translate
            @sortOrder
        section/
            @id
            @translate
            @sortOrder
            @showInDefault
            @showInWebsite
            @showInStore
            class/
            label/
            tab/
            resource/
            group/
                @id
                @translate
                @type
                @sortOrder
                @showInDefault
                @showInWebsite
                @showInStore
                label/
                field/
                    @id
                    @translate
                    @type
                    @sortOrder
                    @showInDefault
                    @showInWebsite
                    @showInStore
                    label/
                    comment/
                    source_model/

Grids

  • Render a list of entity records
  • Allows for sorting, filtering and searching
  • Allows for actions on a group of records

view/adminhtml/ui_component/cms_block_form.xml:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
/form/
    argument/
        @name - data
        @xsi:type - array
        item/
            @name - js_config
            item/
                @name - provider
    settings/
        buttons/
            button/
                @name
                @class
        namespace/
        dataScope/
        deps/
    dataSource/
    fieldset/
        field/

Listing

  • Is the analog to Grid widgets
  • Listings provide Paging, Filters and Columns
  • Works with Collections
  • Uses the Magento\Ui\Components\Listing class
  • Uses the templates/listing/default

Data arguments

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
argument/@name=data
         item/
              @name=js_config
              @xsi:type=array
              item/
                   @name=provider
                   @xsi:type=string
                   (data source here)
              item/
                   @name=deps
                   @xsi:type=string
                   (data source here)
        item/
             @name=buttons
             @xsi:type=array
             item/
                  @name=add
                  @xsi:type=array
                  item/
                       @name=name
                       @name=label
                       @name=class
                       @name=url

Filters

  • Uses the Magento\Ui\Components\Filters class
  • Uses the Magento_UI\js\grid/filters/filters UiComponent

DataSource

  • A UiComponent that provides data to others
  • Doesn't contain data - that's handled by the DataProvider