Skip to content

Customer Attributes

Code Slicer edited this page May 11, 2023 · 3 revisions

Allows managing eav attributes related to customers.
Use it as follows:

public function __construct(
    Migration\Context $context,
    private Migration\Facade\CustomerAttribute $customerAttribute
) {
    parent::__construct($context);
}

create($code, $data)

Create a new attribute. Eg.:

// we suggest checking the available fields here: https://mage2gen.com/?main_version=4
$this->customerAttribute->create('fullname', [
    'type' => 'text',
    'label' => 'Full Name',
    'input' => 'text',
    'visible' => true,
    'required' => false,
    'user_defined' => false,
]);

update($code, $data)

Well, it's pretty much what the name implies. Eg.:

$this->customerAttribute->create('fullname', [
    'required' => true,
]);
Clone this wiki locally