This Magento 2 module extends the Customer entity to support an additional attribute origin_channel
and exposes it via GraphQL.
- Adds a new customer attribute:
origin_channel
- Supports values like:
null
,website
,boutique
- Extends
createCustomerV2
GraphQL mutation to acceptorigin_channel
- Includes plugins and data patch for setup
Place the module inside your Magento installation:
app/code/Practical/ExtendCustomer
- Copy Module
cp -r Practical/ExtendCustomer <magento_root>/app/code/Practical/ExtendCustomer
- Enable and Install
bin/magento module:enable Practical_ExtendCustomer
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento cache:flush
- Verify Attribute
Check the database:
SELECT * FROM eav_attribute WHERE attribute_code = 'origin_channel';
You can also create a customer with the origin_channel
attribute using the Magento 2 REST API.
POST /rest/V1/customers
Full URL Example:
https://app.magento248.test/rest/V1/customers
{
"customer": {
"email": "c.doe@example.com",
"firstname": "John",
"lastname": "Doe",
"extension_attributes": {
"origin_channel": "boutique"
}
},
"password": "Password123"
}
{
"id": 13,
"group_id": 1,
"created_at": "2025-06-25 08:23:43",
"updated_at": "2025-06-25 08:23:43",
"created_in": "Default Store View",
"email": "c.doe@example.com",
"firstname": "John",
"lastname": "Doe",
"store_id": 1,
"website_id": 1,
"addresses": [],
"disable_auto_group_change": 0,
"extension_attributes": {
"is_subscribed": false
},
"custom_attributes": [
{
"attribute_code": "origin_channel",
"value": "boutique"
}
]
}
mutation {
createCustomerV2(
input: {
firstname: "John"
lastname: "Doe"
email: "johre8o4.doe@example.com"
password: "Password123"
origin_channel: boutique
}
) {
customer {
id
firstname
lastname
email
custom_attributes{
code
}
}
}
}
null
website
boutique
Defined in: Model/Source/OriginChannel.php
File | Description |
---|---|
registration.php |
Registers module with Magento |
etc/module.xml |
Declares module version |
etc/di.xml |
Plugin configuration |
etc/extension_attributes.xml |
Declares extension attributes |
etc/schema.graphqls |
Adds GraphQL schema extension |
Plugin/CustomerAccountManagementPlugin.php |
Intercepts customer creation |
Setup/Patch/Data/AddOriginChannelCustomerAttribute.php |
Adds origin_channel to customer entity |
Model/Resolver/Customer/OriginChannel.php |
GraphQL resolver |
bin/magento module:disable Practical_ExtendCustomer
rm -rf app/code/Practical/ExtendCustomer
bin/magento setup:upgrade