0

I have searched lots of links on google but can't find any relevant answer. Can anybody help ? I want to create customer group attribute.

2
  • What sort of attribute are you looking to create? You're more likely to get better answers if you specify exactly what you want/need
    – John
    Commented Feb 13, 2018 at 11:53
  • Need to create customer groups attribute, Not customer attribute.
    – user63697
    Commented Feb 13, 2018 at 12:32

1 Answer 1

0

If you want to add a customer attribute you can do it from a Setup file as follows :

$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
$eavSetup->addAttribute(
    \Magento\Customer\Model\Customer::ENTITY,
    'sample_attribute',
    [
        'type'         => 'varchar',
        'label'        => 'Sample Attribute',
        'input'        => 'text',
        'required'     => false,
        'visible'      => true,
        'user_defined' => true,
        'position'     => 999,
        'system'       => 0,
    ]
);

In case an address attribute is needed its here

4
  • Your code will create customer attribute not customer group attribute.
    – user63697
    Commented Feb 13, 2018 at 12:33
  • i do not think customer groups are eav driven, i think you need to add a column in customer_group table Commented Feb 13, 2018 at 12:46
  • Yes, i yes have already added column but i need to display it at grid and also need to add more columns such as image upload, dropdown etc. it will displays when we open group at admin.
    – user63697
    Commented Feb 13, 2018 at 12:47
  • let me try it on my demo and get back Commented Feb 13, 2018 at 12:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.