Use the data patch setup on AdobeC
Create Setup -> Patch -> Data -> AddCustomAttribute.php
<?php
namespace JJCustomerNetsuiteFieldSetupPatchData;
use MagentoEavSetupEavSetupFactory;
use MagentoFrameworkSetupModuleDataSetupInterface;
use MagentoFrameworkSetupPatchDataPatchInterface;
use MagentoCustomerSetupCustomerSetupFactory;
use MagentoCustomerModelCustomer;
class AddCustomAttribute implements DataPatchInterface
{
private $eavSetupFactory;
private $customerSetupFactory;
private $moduleDataSetup;
public function __construct(
EavSetupFactory $eavSetupFactory,
CustomerSetupFactory $customerSetupFactory,
ModuleDataSetupInterface $moduleDataSetup
) {
$this->eavSetupFactory = $eavSetupFactory;
$this->customerSetupFactory = $customerSetupFactory;
$this->moduleDataSetup = $moduleDataSetup;
}
public function apply()
{
$customerSetup = $this->customerSetupFactory->create([‘setup’ => $this->moduleDataSetup]);
$customerEntity = $customerSetup->getEavConfig()->getEntityType(‘customer’);
$attributeSetId = $customerEntity->getDefaultAttributeSetId();
$customerSetup->addAttribute(Customer::ENTITY, ‘netsuite_id’, [
‘type’ => ‘varchar’,
‘label’ => ‘Netsuite Id’,
‘input’ => ‘text’,
‘required’ => false,
‘visible’ => true,
‘user_defined’ => true,
‘position’ => 999,
‘system’ => 0,
]);
$attribute = $customerSetup->getEavConfig()->getAttribute(Customer::ENTITY, ‘netsuite_id’)
->addData([
‘attribute_set_id’ => $attributeSetId,
‘attribute_group_id’ => $customerSetup->getDefaultAttributeGroupId($attributeSetId),
‘used_in_forms’ => [
‘adminhtml_customer’
],
]);
$attribute->save();
}
public function getAliases()
{
return [];
}
public static function getDependencies()
{
return [];
}
}