Advertisement
Guest User

Untitled

a guest
Jul 29th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. <?php
  2.  
  3. namespace vendorTestModuleSetup;
  4.  
  5. use MagentoCustomerModelCustomer;
  6. use MagentoCustomerSetupCustomerSetup;
  7. use MagentoCustomerSetupCustomerSetupFactory;
  8. use MagentoFrameworkSetupInstallDataInterface;
  9. use MagentoFrameworkSetupModuleContextInterface;
  10. use MagentoFrameworkSetupModuleDataSetupInterface;
  11.  
  12. class InstallData implements InstallDataInterface {
  13.  
  14. /**
  15. * Customer setup factory
  16. *
  17. * @var MagentoCustomerSetupCustomerSetupFactory
  18. */
  19. private $customerSetupFactory;
  20.  
  21. public function __construct(CustomerSetupFactory $customerSetupFactory) {
  22. $this->customerSetupFactory = $customerSetupFactory;
  23. }
  24.  
  25. public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) {
  26. $setup->startSetup();
  27. /** @var CustomerSetup $customerSetup */
  28. $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
  29.  
  30. $customerSetup->addAttribute(Customer::ENTITY, 'client_idn', [
  31. 'label' => 'Client IDN',
  32. 'input' => 'text',
  33. 'required' => false,
  34. 'sort_order' => 40,
  35. 'visible' => true,
  36. 'system' => false,
  37. 'is_used_in_grid' => true,
  38. 'is_visible_in_grid' => true,
  39. 'is_filterable_in_grid' => true,
  40. 'is_searchable_in_grid' => true]
  41. );
  42.  
  43. // add attribute to form
  44. /** @var $attribute */
  45. $attribute = $customerSetup->getEavConfig()->getAttribute('customer', 'client_idn');
  46. $attribute->setData('used_in_forms', ['adminhtml_customer', 'customer_account_create']);
  47. $attribute->save();
  48.  
  49. $setup->endSetup();
  50. }
  51.  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement