Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace vendorTestModuleSetup;
- use MagentoCustomerModelCustomer;
- use MagentoCustomerSetupCustomerSetup;
- use MagentoCustomerSetupCustomerSetupFactory;
- use MagentoFrameworkSetupInstallDataInterface;
- use MagentoFrameworkSetupModuleContextInterface;
- use MagentoFrameworkSetupModuleDataSetupInterface;
- class InstallData implements InstallDataInterface {
- /**
- * Customer setup factory
- *
- * @var MagentoCustomerSetupCustomerSetupFactory
- */
- private $customerSetupFactory;
- public function __construct(CustomerSetupFactory $customerSetupFactory) {
- $this->customerSetupFactory = $customerSetupFactory;
- }
- public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) {
- $setup->startSetup();
- /** @var CustomerSetup $customerSetup */
- $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
- $customerSetup->addAttribute(Customer::ENTITY, 'client_idn', [
- 'label' => 'Client IDN',
- 'input' => 'text',
- 'required' => false,
- 'sort_order' => 40,
- 'visible' => true,
- 'system' => false,
- 'is_used_in_grid' => true,
- 'is_visible_in_grid' => true,
- 'is_filterable_in_grid' => true,
- 'is_searchable_in_grid' => true]
- );
- // add attribute to form
- /** @var $attribute */
- $attribute = $customerSetup->getEavConfig()->getAttribute('customer', 'client_idn');
- $attribute->setData('used_in_forms', ['adminhtml_customer', 'customer_account_create']);
- $attribute->save();
- $setup->endSetup();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement