10 use Magento\Customer\Setup\CustomerSetupFactory;
26 private $customerSetupFactory;
31 private $moduleDataSetup;
39 CustomerSetupFactory $customerSetupFactory,
42 $this->customerSetupFactory = $customerSetupFactory;
43 $this->moduleDataSetup = $moduleDataSetup;
50 public function apply()
53 $customerSetup = $this->customerSetupFactory->create([
'setup' => $this->moduleDataSetup]);
56 $this->moduleDataSetup->getConnection()->insertForce(
57 $this->moduleDataSetup->getTable(
'customer_group'),
58 [
'customer_group_id' => 0,
'customer_group_code' =>
'NOT LOGGED IN',
'tax_class_id' => 3]
60 $this->moduleDataSetup->getConnection()->insertForce(
61 $this->moduleDataSetup->getTable(
'customer_group'),
62 [
'customer_group_id' => 1,
'customer_group_code' =>
'General',
'tax_class_id' => 3]
64 $this->moduleDataSetup->getConnection()->insertForce(
65 $this->moduleDataSetup->getTable(
'customer_group'),
66 [
'customer_group_id' => 2,
'customer_group_code' =>
'Wholesale',
'tax_class_id' => 3]
68 $this->moduleDataSetup->getConnection()->insertForce(
69 $this->moduleDataSetup->getTable(
'customer_group'),
70 [
'customer_group_id' => 3,
'customer_group_code' =>
'Retailer',
'tax_class_id' => 3]
73 $customerSetup->installEntities();
75 $customerSetup->installCustomerForms();
77 $disableAGCAttribute = $customerSetup->getEavConfig()->getAttribute(
'customer',
'disable_auto_group_change');
78 $disableAGCAttribute->setData(
'used_in_forms', [
'adminhtml_customer']);
79 $disableAGCAttribute->save();
83 'label' =>
'VAT number',
91 'label' =>
'VAT number validity',
97 'label' =>
'VAT number validation request ID',
102 'vat_request_date' => [
103 'label' =>
'VAT number validation request date',
108 'vat_request_success' => [
109 'label' =>
'VAT number validation request success',
117 $customerSetup->addAttribute(
'customer_address',
$attributeCode, $attributeParams);
120 $vatIdAttribute = $customerSetup->getEavConfig()->getAttribute(
'customer_address',
'vat_id');
121 $vatIdAttribute->setData(
123 [
'adminhtml_customer_address',
'customer_address_edit',
'customer_register_address']
125 $vatIdAttribute->save();
127 $entities = $customerSetup->getDefaultEntities();
128 foreach ($entities as $entityName =>
$entity) {
129 $customerSetup->addEntityType($entityName,
$entity);
132 $customerSetup->updateAttribute(
139 $migrationSetup = $this->moduleDataSetup->createMigrationSetup();
141 $migrationSetup->appendClassAliasReplace(
142 'customer_eav_attribute',
148 $migrationSetup->doUpdateClassAliases();
__construct(CustomerSetupFactory $customerSetupFactory, \Magento\Framework\Setup\ModuleDataSetupInterface $moduleDataSetup)
const FIELD_CONTENT_TYPE_PLAIN