定制 elite-remote-firm/magento2-customer-attribute 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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 uuid on the GraphQL Customer type for authenticated queries
  • Displays uuid in 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 (customer query 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-customer
  • magento/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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: proprietary
  • 更新时间: 2026-06-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固