elite-remote-firm/magento2-customer-attribute
最新稳定版本:1.0.0
Composer 安装命令:
composer require elite-remote-firm/magento2-customer-attribute
包简介
Adds a unique, read-only UUID attribute to Magento 2 customers with GraphQL and admin grid support.
README 文档
README
Magento 2 module that adds a unique, system-managed uuid attribute to customers.
Features
- Creates a customer EAV attribute
uuid(RFC 4122 v4 UUID) - Enforces uniqueness at the EAV layer (
unique = true) with collision checks during generation - Automatically assigns UUIDs to existing customers on module installation
- Automatically assigns UUIDs to newly created customers
- Exposes
uuidon the GraphQLCustomertype for authenticated queries - Displays
uuidin the admin customer grid - Keeps the attribute read-only in admin (not included in any customer edit forms; save attempts are ignored)
Assumptions
- UUIDs are version 4 (random) strings generated via
ramsey/uuid - The attribute is global-scoped and not editable by admins or customers through any save path covered by
CustomerRepositoryInterface - GraphQL access follows Magento's standard customer authentication (
customerquery requires a valid bearer token) - The module is intended for Magento Open Source / Adobe Commerce 2.4.x (tested against 2.4.9)
- The UUID field is shown on the admin customer form as a disabled field (read-only) for visibility; the authoritative display for admins is the customer grid column
Requirements
- PHP 8.3+
- Magento 2.4.x
magento/module-customermagento/module-customer-graph-ql
Installation
Via Composer (recommended)
Add the package repository to your project's composer.json:
{
"repositories": [
{
"type": "path",
"url": "app/code/EliteRemoteFirm/CustomerAttribute",
"options": {
"symlink": true
}
}
],
"require": {
"elite-remote-firm/magento2-customer-attribute": "1.0.0"
}
}
Then run:
composer require elite-remote-firm/magento2-customer-attribute:1.0.0 bin/magento module:enable EliteRemoteFirm_CustomerAttribute bin/magento setup:upgrade bin/magento cache:flush bin/magento indexer:reindex customer_grid
Manual installation
Copy the module to app/code/EliteRemoteFirm/CustomerAttribute, then run:
bin/magento module:enable EliteRemoteFirm_CustomerAttribute bin/magento setup:upgrade bin/magento cache:flush bin/magento indexer:reindex customer_grid
GraphQL API
Authenticate as a customer, then query the uuid field:
mutation { generateCustomerToken(email: "customer@example.com", password: "Password123!") { token } }
{
customer {
firstname
lastname
email
uuid
}
}
Pass the token in the Authorization: Bearer <token> header.
The uuid field is also available on Customer objects returned by mutations such as createCustomerV2 and updateCustomerV2.
Admin
After installation and reindexing, the UUID column appears in Customers > All Customers. The value is visible in the grid but cannot be edited on the customer form because the attribute is excluded from all admin forms.
Testing
Unit tests
./vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist \ app/code/EliteRemoteFirm/CustomerAttribute/Test/Unit
Integration tests
Ensure your integration test DB is configured (dev/tests/integration/etc/install-config-mysql.php), then run:
./vendor/bin/phpunit -c dev/tests/integration/phpunit.xml.dist \ app/code/EliteRemoteFirm/CustomerAttribute/Test/Integration
Module structure
EliteRemoteFirm/CustomerAttribute/
├── Setup/Patch/Data/
│ ├── AddUuidCustomerAttribute.php # Creates the EAV attribute
│ └── PopulateExistingCustomerUuids.php # Backfills existing customers
├── Model/
│ ├── UuidGenerator.php # UUID generation + uniqueness check
│ └── Resolver/CustomerUuid.php # GraphQL resolver
├── Plugin/CustomerRepository/UuidPlugin.php # Auto-assign + read-only enforcement
├── etc/
│ ├── module.xml
│ ├── di.xml
│ └── schema.graphqls
└── view/adminhtml/ui_component/customer_listing.xml
Uninstall
bin/magento module:disable EliteRemoteFirm_CustomerAttribute bin/magento setup:upgrade
To fully remove the attribute, a custom uninstall routine would be required. This module does not ship an uninstall script.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: proprietary
- 更新时间: 2026-06-11