一键导入
admin-ui-grid
Build Magento 2 admin grids using UI Component listing XML, data providers, and admin controllers with proper ACL integration
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Build Magento 2 admin grids using UI Component listing XML, data providers, and admin controllers with proper ACL integration
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Implement Magento 2 GraphQL resolvers — define schema.graphqls types, write query and mutation resolvers, and handle authorization
Run Magento 2 CLI commands through Warden's Docker environment: warden shell, bin/magento, composer, Redis/Valkey, Varnish, OpenSearch, RabbitMQ, n98-magerun2, mutagen sync, and env lifecycle.
Adapt Luma-oriented Magento 2 modules to work with Hyva themes — replace RequireJS and Knockout with Alpine.js, Tailwind CSS, and ViewModels
Configure Magento 2 dependency injection — preferences, virtual types, constructor arguments, and proxy generation via di.xml
Implement Magento 2 plugins (interceptors) following best practices for before, after, and around method interception
Create a new Magento 2 module with the required directory structure, registration files, composer autoloading, and module sequence declarations
| name | admin-ui-grid |
| description | Build Magento 2 admin grids using UI Component listing XML, data providers, and admin controllers with proper ACL integration |
| installed_version | 1.0.0 |
| magehub_version | 0.1.13 |
Admin grids in Magento 2 are built with the UI Component framework. A grid requires three coordinated pieces: a listing XML file that defines columns and filters, a data provider that supplies the collection, and a controller action with a layout handle that loads the UI component.
Create the listing file at view/adminhtml/ui_component/<entity>_listing.xml.
The root <listing> element contains <dataSource>, <listingToolbar>, and
<columns> sections. The data source binds to a data provider class. The
toolbar configures bookmarks, column controls, filters, paging, and mass
actions. Each <column> defines the field name, data type, label, and
optional filter/sorting configuration.
The data provider class extends
Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider or
implements DataProviderInterface. Register it via di.xml by adding the
collection to Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory
arguments. The collection name in di.xml must match the <dataSource> name in
the listing XML suffixed with _data_source.
Create an admin controller at Controller/Adminhtml/<Entity>/Index.php that
returns a resultPageFactory->create() response. The layout handle
view/adminhtml/layout/<route>_<entity>_index.xml must reference the listing
UI component via <uiComponent name="<entity>_listing"/>.
Define ACL resources in etc/acl.xml and reference them in the controller's
ADMIN_RESOURCE constant. Add a menu item in etc/adminhtml/menu.xml that
maps to the controller route so the grid is accessible from the admin sidebar.
Add mass actions to the toolbar for bulk operations like delete or status
change. Each mass action maps to a dedicated controller action. Enable inline
editing by adding the editor configuration to columns that support it.
Complete admin grid UI component defining data source, toolbar with filters and paging, and typed columns with sorting
<?xml version="1.0" encoding="UTF-8"?>
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<argument name="data" xsi:type="array">
<item name="js_config" xsi:type="array">
<item name="provider"
xsi:type="string">vendor_module_entity_listing.vendor_module_entity_listing_data_source</item>
</item>
</argument>
<settings>
<spinner>vendor_module_entity_columns</spinner>
<deps>
<dep>vendor_module_entity_listing.vendor_module_entity_listing_data_source</dep>
</deps>
</settings>
<dataSource name="vendor_module_entity_listing_data_source" component="Magento_Ui/js/grid/provider">
<settings>
<updateUrl path="mui/index/render"/>
</settings>
<aclResource>Vendor_Module::entity_view</aclResource>
<dataProvider class="Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider"
name="vendor_module_entity_listing_data_source">
<settings>
<requestFieldName>id</requestFieldName>
<primaryFieldName>entity_id</primaryFieldName>
</settings>
</dataProvider>
</dataSource>
<listingToolbar name="listing_top">
<bookmark name="bookmarks"/>
<columnsControls name="columns_controls"/>
<filterSearch name="fulltext"/>
<filters name="listing_filters"/>
<paging name="listing_paging"/>
</listingToolbar>
<columns name="vendor_module_entity_columns">
<selectionsColumn name="ids" sortOrder="10">
<settings>
<indexField>entity_id</indexField>
</settings>
</selectionsColumn>
<column name="entity_id" sortOrder="20">
<settings>
<filter>textRange</filter>
<label translate="true">ID</label>
<sorting>asc</sorting>
</settings>
</column>
<column name="name" sortOrder="30">
<settings>
<filter>text</filter>
<label translate="true">Name</label>
</settings>
</column>
<column name="created_at" class="Magento\Ui\Component\Listing\Columns\Date"
component="Magento_Ui/js/grid/columns/date" sortOrder="40">
<settings>
<filter>dateRange</filter>
<dataType>date</dataType>
<label translate="true">Created At</label>
</settings>
</column>
</columns>
</listing>
Index controller that loads the admin page layout and enforces ACL-based access control
<?php
declare(strict_types=1);
namespace Vendor\Module\Controller\Adminhtml\Entity;
use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Framework\View\Result\PageFactory;
use Magento\Framework\View\Result\Page;
class Index extends Action
{
public const ADMIN_RESOURCE = 'Vendor_Module::entity_manage';
public function __construct(
Context $context,
private readonly PageFactory $resultPageFactory
) {
parent::__construct($context);
}
public function execute(): Page
{
$resultPage = $this->resultPageFactory->create();
$resultPage->setActiveMenu('Vendor_Module::entity');
$resultPage->getConfig()->getTitle()->prepend(__('Manage Entities'));
return $resultPage;
}
}
Admin layout XML that loads the listing UI component into the page content area
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<uiComponent name="vendor_module_entity_listing"/>
</referenceContainer>
</body>
</page>
Path template:
view/adminhtml/ui_component/{{entity}}_listing.xml
UI Component listing XML defining data source, toolbar, and column configuration
<?xml version="1.0" encoding="UTF-8"?>
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<argument name="data" xsi:type="array">
<item name="js_config" xsi:type="array">
<item name="provider"
xsi:type="string">{{entity}}_listing.{{entity}}_listing_data_source</item>
</item>
</argument>
<settings>
<spinner>{{entity}}_columns</spinner>
<deps>
<dep>{{entity}}_listing.{{entity}}_listing_data_source</dep>
</deps>
</settings>
</listing>
Path template:
Controller/Adminhtml/{{entityClass}}/Index.php
Admin grid index controller with ACL protection and page layout initialization
<?php
declare(strict_types=1);
namespace {{vendor}}\{{module}}\Controller\Adminhtml\{{entityClass}};
use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Framework\View\Result\PageFactory;
use Magento\Framework\View\Result\Page;
class Index extends Action
{
public const ADMIN_RESOURCE = '{{vendor}}_{{module}}::{{entity}}_manage';
public function __construct(
Context $context,
private readonly PageFactory $resultPageFactory
) {
parent::__construct($context);
}
public function execute(): Page
{
$resultPage = $this->resultPageFactory->create();
$resultPage->setActiveMenu('{{vendor}}_{{module}}::{{entity}}');
$resultPage->getConfig()->getTitle()->prepend(__('Manage {{entityLabel}}'));
return $resultPage;
}
}