Advertisement
Guest User

Untitled

a guest
Aug 21st, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. class InstallData implements InstallDataInterface
  2. {
  3. /**
  4. * @var AttributeSetFactory $_attributeSetFactory
  5. */
  6. protected $_attributeSetFactory;
  7.  
  8. /**
  9. * @var CustomerSetupFactory $_customerSetupFactory
  10. */
  11. protected $_customerSetupFactory;
  12.  
  13. /**
  14. * @param CustomerSetupFactory $customerSetupFactory
  15. */
  16. public function __construct(
  17. CustomerSetupFactory $customerSetupFactory,
  18. AttributeSetFactory $attributeSetFactory
  19. )
  20. {
  21. $this->_customerSetupFactory = $customerSetupFactory;
  22.  
  23. $this->_attributeSetFactory = $attributeSetFactory;
  24. }
  25.  
  26. /**
  27. * @param SchemaSetupInterface $setup
  28. * @param ModuleContextInterface $context
  29. */
  30. public function install(
  31. ModuleDataSetupInterface $setup,
  32. ModuleContextInterface $context
  33. )
  34. {
  35. $setup->startSetup();
  36.  
  37. $customerSetup = $this->_customerSetupFactory->create(['setup' => $setup]);
  38.  
  39. $customerEntity = $customerSetup->getEavConfig()
  40. ->getEntityType('customer');
  41. $attributeSetId = $customerEntity->getDefaultAttributeSetId();
  42.  
  43. /** @var $attributeSet AttributeSet */
  44. $attributeSet = $this->_attributeSetFactory->create();
  45. $attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId);
  46.  
  47. $customerSetup->addAttribute('customer_address', 'short_name', [
  48. 'default' => '',
  49. 'input' => 'text',
  50. 'label' => 'Address short name',
  51. 'length' => 32,
  52. 'nullable' => false,
  53. 'required' => true,
  54. 'type' => Table::TYPE_TEXT,
  55. 'user_defined' => false,
  56. 'visible' => true,
  57. ]);
  58.  
  59. $attribute = $customerSetup->getEavConfig()->getAttribute('customer_address', 'short_name')
  60. ->addData([
  61. 'attribute_group_id' => $attributeGroupId,
  62. 'attribute_set_id' => $attributeSetId,
  63. 'used_in_forms' => [
  64. 'adminhtml_customer_address',
  65. 'customer_address_edit',
  66. 'customer_register_address',
  67. ],
  68. ]);
  69.  
  70. $attribute->save();
  71.  
  72. $setup->endSetup();
  73. }
  74. }
  75.  
  76. /*jshint browser:true jquery:true*/
  77. /*global alert*/
  78. define([], function() {
  79. /**
  80. * @param addressData
  81. * Returns new address object
  82. */
  83. return function (addressData) {
  84. console.log(addressData);
  85. return {
  86. customerAddressId: addressData.id,
  87. email: addressData.email,
  88. countryId: addressData.country_id,
  89. regionId: addressData.region_id,
  90. ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement