Light API 0.18.0 is a public beta: a minor release such as 0.19.0 may still break. What that means for your module
Light
Developer guideRecipes

Light lists

Your records in a Light list with its filters, and your columns, bulk actions and filters on another module's list.

A Light list is the IndexTable block with a provider: columns, tabs, search, filters, sorting, bulk actions and row actions, drawn the same way on every Light page. This recipe writes a provider for your own data, gives it filters, and adds columns, bulk actions and filters to another module's list.

When to use it

  • Your module has records the merchant works through: requests, returns, subscriptions. A Light list replaces the stock grid in simple mode.
  • To show one more fact on a core list, add a column to it instead of a new screen (Built for Light, rule 2).

How a list loads

The page renders first, and the list asks for its rows in a request of its own, so a slow provider doesn't hold up the page. With the block argument first_rows, the page computes the first page itself and the list draws it without that request; Light's orders, products and customers lists do this. Leave it off for a provider that is slow, since the page then waits for it. Light checks your provider's ACL resource before it calls getRows(), and the extensions of other modules add their cells to your rows:

To turn it on for your list, add the argument to your IndexTable block, as the orders list does:

app/code/Mrx/Orders/view/adminhtml/layout/light_orders_index.xml
<argument name="first_rows" xsi:type="boolean">true</argument>

The first page is the one light/table/data would answer for the same state: the page reads tab, q, sort, dir, page, the channel and every visible filter's own key (?payment=pending) from its own URL, and the block's default_tab, default_sort, page_size and fixed filters; a fixed filter wins over the URL. It never reads a nested filter[...] or a hidden filter from the URL. When the list's state turns out different, or the provider throws (logged), the list asks for its rows as before. A list that arrives with its rows fires mrx:table:loaded right after your scripts of the same task attached; a script that may run later checks indexTable.get(element).loadedOnce (and .rows) as well as listening for the event.

Steps

1. The provider

A class that implements ProviderInterface answers the table's questions: its columns, tabs, default sort, search placeholder, bulk actions, empty state and rows:

app/code/Mrx/Light/Api/IndexTable/ProviderInterface.php
public function getRows(Query $query): array;

Light lets go of the admin session before it calls your provider, so badges, rows and search answers run in parallel: read the session, never write to it here; a write is lost.

The pilot's provider reads the requests through its own backend service. Its empty state says what will appear:

app/code/Disrex/RequestAnAccountLight/Model/IndexTable/RequestsProvider.php
'text' => (string)__('When a business customer fills in the sign-up form, the request shows up here.'),

Each row carries id, url (the row opens it), cells and meta. meta holds the facts row actions test, such as status.

Prop

Type

2. Register it

The provider goes in the ProviderPool argument providers (pool table_providers), keyed by the table code, as a \Proxy. The page's layout puts Mrx\Light\Block\IndexTable with that code in content (Your own list and detail pages). A provider class with #[RequiresModule] makes the list not exist while its module is off: the block renders nothing, and the list's data URL answers 404.

3. Bulk and row actions

  • Bulk actions come from getBulkActions(): a label, a route that receives ids[], a resource, a tone and a confirm text for destructive ones. The route is your own JSON controller (Your own list and detail pages).
  • Asking from the route. When only the route knows that an action needs the admin's yes (it would replace something the selection holds), it answers HTTP 409 with {"success": false, "message": "...", "confirm": {"title": "...", "message": "...", "label": "...", "param": "confirmed"}} and writes nothing. The list shows that question and, on yes, posts the same ids[] again with param (default confirmed) set to 1. Light's category list does this for "Show in menu" when a language has its own setting.
  • Row actions come from a provider that also implements RowActionsInterface: each names a bulk action and the meta it needs, such as "Mark handled" when {status: 'new'}.
  • Row-only actions. An action that makes sense on one record at a time, such as opening it in an editor, sets row_only (since 0.3.0): the bulk bar leaves it out, and a row action that names it runs it on that one row (ids[] holds one id). A list whose bulk actions are all row-only gets no checkboxes. Pair it with mode download and target _blank to open a page in a new tab without a popup blocker: the form posts in the click.

The keys of a bulk action:

Prop

Type

4. Columns on another module's list

A class that implements ProviderExtensionInterface adds columns and bulk actions to a list it doesn't own, and fills them in decorateRows(). It goes in the IndexTable\ExtensionPool argument extensions (pool table_extensions), keyed by the table code and then by your key. Returns adds a return status column to the orders list:

app/code/Mrx/Returns/etc/adminhtml/di.xml
<item name="orders" xsi:type="array">
    <item name="returns" xsi:type="object">Mrx\Returns\Model\IndexTable\OrdersReturnStatus\Proxy</item>
</item>

Its column and bulk action keys start with <your key>_, and never reuse a key the table has.

  • A column or bulk action with another key is skipped and logged, so an extension never replaces the list's own column or action.
  • Your columns follow the provider's own, or come right after the column named in after. They are never sortable, and take part in the admin's column choice like the others (hideable, default_hidden).
  • Your bulk actions go before the provider's first critical action, and only show with their resource.
  • decorateRows() gets the rows of the page that is shown, after getRows(), with the same Query. Only your own columns' cells are taken, matched by row id, so fetch them for the whole page in one query.
  • An extension that throws in getColumns() or getBulkActions() adds nothing; one that throws in decorateRows() keeps its columns with empty cells. The list and the other extensions keep working.

5. Filters

Since 0.6.0 a provider that implements FilterableProviderInterface declares its filters in getFilters(), in menu order, as FilterDefinition objects. Offer 3 to 8 filters, the most used first, not one per column: the search box covers text, and the tabs are the default views. A filter has no default value, so the merchant never sees a chip they didn't pick.

The orders list builds its filters in a class of their own, which Orders::getFilters() returns:

app/code/Mrx/Orders/Model/Filter/OrderFilters.php
FilterDefinition::numberRange(self::TOTAL, (string)__('Total'), $this->currency()),
FilterDefinition::multiselect(self::COUNTRY, (string)__('Country'), $this->countryOptions()),
FilterDefinition::select(self::CUSTOMER, (string)__('Customer'), [
    ['value' => self::CUSTOMER_GUEST, 'label' => (string)__('Guest (customer filter)')],
    ['value' => self::CUSTOMER_ACCOUNT, 'label' => (string)__('Has an account')],
]),

Leave a filter out when this shop has nothing to offer in it: the orders list declares Delivery method and the pickup steps of Shipping status only on a shop with pickup, and Order status only on a shop with a status of its own. Options that come from your data (the payment methods and countries on orders) are read once an hour from an index and kept in the cache, because getFilters() runs on every request of the list.

The named constructors:

Prop

Type

A key matches ^[a-z][a-z0-9_]{0,31}$ and is none of tab, q, sort, dir, page, limit, channel, filter, provider, key, form_key, isAjax, id. A definition that breaks a rule throws when it is built; the list then logs it and shows no filters, and bin/magento mrx:light:doctor reports it as table_filter. getFilters() runs several times per request, so build the list once and keep it.

Reading the values. Light parses and validates every value before getRows() runs. Read it with Query::getFilterValue($key), which returns a FilterValue or null, and bind what it returns:

Prop

Type

Query::$filters and getFilter() keep the raw strings, the channel included, as before.

  • Every filter hits an index. A condition on an indexed column, an IN (subselect) on an indexed column, or an EXISTS on an indexed foreign key the list already uses. Never a per-row model load or a GROUP BY over a whole table. Add a missing index in your module's db_schema.xml, with a comment that names the list and the filter.
  • Invalid input never fails. An unknown key, a value that isn't an option, a bad date or more than 12 filters: Light drops what it can't use, and an old or edited link keeps opening.
  • Long option lists. More than 30 inline options, or a FilterOptionsInterface, load when the merchant opens the filter, through light/table/options (cached for an hour per list, filter and search; at most 50 options, or the filter's withOptionLimit()). getLabels() names the values in the URL, and a value it leaves out is dropped. A select or multiselect with fewer than two inline options doesn't show, and a link that still carries its key (?payment_method=... from when the shop had two) shows the whole list. A tree gives each option a depth, which the editor indents; Catalog's Category filter on the products and Stock lists is one, shown below.
  • Hidden filters. A fixed scope, such as a customer's returns on the customer page, is FilterDefinition::hidden(). The block's filters argument or a page script sets it; it travels in the data URL as filter[key] and is not a security boundary: ACL is.
  • Counting. Mrx\Light\Model\IndexTable\PageCounter::fetchPage($select, $query) fetches one row more than the page: a short page ends the list without a count. A filtered or searched list counts with a cap of 10,000; above it your getRows() answer carries total_capped => true and the pager says "10,000+". That count runs under a 200 ms time limit (MariaDB and MySQL): a rare value on a big shop can still make it read the whole tab, and when the limit stops it the count is skipped. Your answer then carries total_known => false with the rows seen so far as total, and the pager says "1–50" with Next on while pages come back full. A tab without filters or a search counts exactly. If your "total" is not a row count (a tree paged by branches, where the pager draws ceil(total / pageSize) pages), add range => ['from' => first row of the page, 'to' => last row, 'total' => exact rows] and the footer prints it instead of the pager figure; Light drops a range that does not fit the page's rows. The footer then offers a "Count" button (since 0.17.0, from the table config's countUrl): it asks light/table/count for the exact total of that view, with your fixed filters, and a total past 10,000 reads "10,000+". Nothing in your provider changes. Return fetchPage()'s answer as it is, or pass both keys on when you count yourself, as Orders::getRows() does.

A tree of options. The Category filter of the products and Stock lists passes a FilterOptionsInterface to FilterDefinition::select(), so the tree only loads when the merchant opens the filter. Without a search, getOptions() returns the tree in order, each option with its name and depth. With one, it lists each match with its path, so two categories with one name stay apart:

app/code/Mrx/Catalog/Model/Filter/CategoryFilterOptions.php
if ($needle !== '') {
    if (!str_contains(mb_strtolower($path), $needle)) {
        continue;
    }
    $options[] = ['value' => (string)$category['id'], 'label' => $category['path']];
    continue;
}

A request answers at most 50 options, and a search narrows them. A tree needs its whole shape when the filter opens, so the Category filter asks for more with withOptionLimit() (Light allows up to FilterDefinition::MAX_OPTION_LIMIT, 1,000): a shop with 300 categories sees all of them, the deep ones too. Light passes the filter's limit to getOptions() and cuts the answer to it; an answer that reaches the limit gets the line "Type to find more." under it. Keep the default for a flat list (products, customers): every option costs the answer bytes, and the merchant searches anyway.

app/code/Mrx/Catalog/Model/Filter/ProductFilters.php
return FilterDefinition::select(self::CATEGORY, (string)__('Category'), $this->categories)
    ->withOptionLimit(FilterDefinition::MAX_OPTION_LIMIT);

getLabels() runs whenever a request carries the filter, because it is what validates a value, so it reads only the values it is given (two queries by primary key and path, never the whole tree). getOptions() may read more: Light keeps its answer an hour.

In the URL. Each visible filter is a page URL key next to tab, q, sort, dir and page: ?payment=pending,authorized&date=last_7_days&total=50..200. A multiselect joins its values with commas, a date range is a preset key or 2026-10-01..2026-10-07, a number range is min..max with either side empty. The data request carries the same values as filter[key]=value.

In the browser. Light draws the filters; you write none of it. The list gets a Filter button (a popover on desktop, a bottom sheet on phones) with one editor per type: checkboxes for a multiselect, radio buttons for a select, a boolean and the date presets (plus "Custom" with two date inputs), two inputs for a number range, and a search box over the options of a lazy filter. Applied filters show as chips under the toolbar, each with a remove button, and "Clear all" from two chips. A hidden filter and a filter the block fixes through its filters argument never show. Phones also get a Sort button that lists each sortable column both ways, with "Default order" when the list's default sort is no column. Each change adds a history entry, so Back and Forward step through the views. A page script can set a filter with indexTable.get(root).setFilter(key, value) and hear every change in the event mrx:table:state; the UI kit describes the markup and the keyboard.

6. Filters on another module's list

A class in the table_extensions pool may implement FilterExtensionInterface, on its own or next to ProviderExtensionInterface. Its filter keys start with <your key>_, and it can't add a hidden filter. It never touches the list's query: it returns the ids of the rows that match, as a Select of one column, and Light adds <row id> IN (<your select>) to the list's rows and count queries. That works for lists built on a Select, a collection or search criteria alike, and the list's table aliases stay its own.

Returns adds the filter Return (returns_state: requested, in progress, returned) to the orders list, from the same class that adds the Return column. Its select reads rma_entity by its indexed status_id and returns the orders whose column shows the picked states:

app/code/Mrx/Returns/Model/IndexTable/OrdersReturnStatus.php
public function getMatchingIds(string $key, FilterValue $value, Query $query): Select
{
    return $this->query->orderIdsWithState($value->getValues());
}

Match what your column shows. An order with a return to review and another one under way shows "Return requested", so "in progress" leaves it out. Check a filter's definition against the column's: Returns' unit test runs the select on SQLite next to resolve(), the method the column uses.

Put values into your select with where('col IN (?)', $values) or quoteInto(), never as named binds (:status with Select::bind()). Magento's database adapter turns a Select into text before it reads the bind, so the placeholder would reach the database unbound. Light treats a select that carries a bind as broken: it logs it and drops your filter.

Only a list that implements ExtensionFilterTargetInterface takes your filters; getRowIdTable() names the table whose primary keys its row ids are. The lists of Light that take them:

List codeRow ids are the primary keys ofTakes extension filters
orderssales_orderYes, since 0.6.0
productscatalog_product_entity (products with variants, not their variants)Yes, since 0.6.0
inventory (Stock)catalog_product_entity (the products that hold a quantity, variants included)Yes, since 0.6.0
customerscustomer_entityYes, since 0.6.0
returnsrma_entity (module-rma's return table)Yes, since 0.6.0
every other Light listNot yet: columns and row actions only

A list of another module may take them too; its own documentation names the table. Such a list calls Mrx\Light\Model\IndexTable\ExtensionFilters::apply($select, 'o.entity_id', $query) (or applyToCollection()) on its rows and count queries. An extension that throws in getFilters() adds nothing; one that throws in getMatchingIds() loses its filter for that request, and the list still loads. The doctor warns when you add filters to a list that doesn't take them.

Sorting

A column sorts only with sortable: true, and QueryFactory accepts no other key. Map the key to an SQL expression from a constant map, as OrderList does, never interpolate it, and always add a tie-break on the row id. Make a new column sortable only when an index serves that order on the list's default tab, or when the list never grows past a few thousand rows. Extension columns are never sortable. On a phone, the list's Sort button offers each sortable column both ways, and "Default order" first when your default sort is no column.

While the rows load, the list shows skeleton rows with its own column count, and a reload slower than 200 ms swaps the old rows for skeleton rows; you write nothing for that. A list or search of your own outside Block\IndexTable gets the same with Mrx_Light/js/loader and the table or list preset (Design system, Loading states).

What the admin sees

The pilot's Light list: tabs, search, and the row menu with Mark handled

With filters, the orders list shows a Filter button next to the search box, the filters that are on as chips under it, and a phone sheet of the same filters:

The orders list with the filter panel open on its first screen: Payment, Shipping status, Date, Payment method, Total, Country and Customer, with two chips under the toolbar

  • Simple mode. The list with its tabs, search and sortable columns, checkboxes for bulk actions and a row menu for row actions. The admin chooses and orders columns; Light remembers it per admin.
  • Advanced mode. The stock grid. With a route map, the list's mode switch opens it (The advanced view, the route map and header actions).

ACL

getAclResource() guards the whole list, and each bulk action its own resource.

Check it

  • bin/magento mrx:light:doctor --module=<your module>: unknown_key and wrong_area catch a misregistered provider or extension, table_filter a filter key that is malformed, reserved, used twice or lacks your prefix.
  • light/table/data sends a Server-Timing header (rows, count, ext, total): the browser's network panel shows where the time goes.
  • Copy the list checks of tests/playwright/pilot-request-an-account.spec.ts.

Pitfalls

  • Stock mass-action controllers (MassAction\Filter, selected[] and namespace, a redirect) are not bulk targets. Add your own controller that calls your service.
  • Long bulk work goes to cron or the message queue, answers with a toast, and reports through a Home to-do.
  • A bulk action can't ask for a value yet. Edit values in bulk in the advanced view.
  • The value pickers in products-index.js are internal.
  • Extension columns can't be sorted, and a filter extension works only on a list that implements ExtensionFilterTargetInterface.
  • A language pack can translate a short label differently from your module: a pack that renders "Shipping" as "Aflevering" wins over your own nl_NL.csv, so a filter option "Shipping" would read "Aflevering" next to a badge that says "Verzenden". Give an option a key of its own (Shipping (delivery method)), translate that key, and map it back to the plain word in en_US.csv and en_GB.csv. The orders filters do this for "Shipping", "Guest", "Pending" and "Authorized".
  • ?filter=value links from other pages (a Home to-do, an email) keep working as long as the key is declared and visible: a link to ?delivery=pickup opens the orders list on pickup orders only on a shop that offers pickup. On another shop Light ignores the key, as it does any key it doesn't know.

Last updated on

On this page