/** * {@inheritdoc} * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { /** @var CustomerSetup $customerSetup */ $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]); $setup->startSetup(); // insert default customer groups $setup->getConnection()->insertForce($setup->getTable('customer_group'), ['customer_group_id' => 0, 'customer_group_code' => 'NOT LOGGED IN', 'tax_class_id' => 3]); $setup->getConnection()->insertForce($setup->getTable('customer_group'), ['customer_group_id' => 1, 'customer_group_code' => 'General', 'tax_class_id' => 3]); $setup->getConnection()->insertForce($setup->getTable('customer_group'), ['customer_group_id' => 2, 'customer_group_code' => 'Wholesale', 'tax_class_id' => 3]); $setup->getConnection()->insertForce($setup->getTable('customer_group'), ['customer_group_id' => 3, 'customer_group_code' => 'Retailer', 'tax_class_id' => 3]); $customerSetup->installEntities(); $customerSetup->installCustomerForms(); $disableAGCAttribute = $customerSetup->getEavConfig()->getAttribute('customer', 'disable_auto_group_change'); $disableAGCAttribute->setData('used_in_forms', ['adminhtml_customer']); $disableAGCAttribute->save(); $attributesInfo = ['vat_id' => ['label' => 'VAT number', 'type' => 'static', 'input' => 'text', 'position' => 140, 'visible' => true, 'required' => false], 'vat_is_valid' => ['label' => 'VAT number validity', 'visible' => false, 'required' => false, 'type' => 'static'], 'vat_request_id' => ['label' => 'VAT number validation request ID', 'type' => 'static', 'visible' => false, 'required' => false], 'vat_request_date' => ['label' => 'VAT number validation request date', 'type' => 'static', 'visible' => false, 'required' => false], 'vat_request_success' => ['label' => 'VAT number validation request success', 'visible' => false, 'required' => false, 'type' => 'static']]; foreach ($attributesInfo as $attributeCode => $attributeParams) { $customerSetup->addAttribute('customer_address', $attributeCode, $attributeParams); } $vatIdAttribute = $customerSetup->getEavConfig()->getAttribute('customer_address', 'vat_id'); $vatIdAttribute->setData('used_in_forms', ['adminhtml_customer_address', 'customer_address_edit', 'customer_register_address']); $vatIdAttribute->save(); $entities = $customerSetup->getDefaultEntities(); foreach ($entities as $entityName => $entity) { $customerSetup->addEntityType($entityName, $entity); } $customerSetup->updateAttribute('customer_address', 'street', 'backend_model', 'Magento\\Eav\\Model\\Entity\\Attribute\\Backend\\DefaultBackend'); $migrationSetup = $setup->createMigrationSetup(); $migrationSetup->appendClassAliasReplace('customer_eav_attribute', 'data_model', Migration::ENTITY_TYPE_MODEL, Migration::FIELD_CONTENT_TYPE_PLAIN, ['attribute_id']); $migrationSetup->doUpdateClassAliases(); $setup->endSetup(); }
/** * {@inheritdoc} * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { $setup->startSetup(); /** @var CustomerSetup $customerSetup */ $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]); if (version_compare($context->getVersion(), '2.0.1', '<')) { $entityAttributes = ['customer' => ['website_id' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => false], 'created_in' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => false, 'is_searchable_in_grid' => true], 'email' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => true], 'group_id' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => false], 'dob' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => false], 'taxvat' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => false, 'is_searchable_in_grid' => true], 'confirmation' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => false], 'created_at' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => false], 'gender' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => false]], 'customer_address' => ['company' => ['is_used_in_grid' => true, 'is_visible_in_grid' => false, 'is_filterable_in_grid' => false, 'is_searchable_in_grid' => true], 'street' => ['is_used_in_grid' => true, 'is_visible_in_grid' => false, 'is_filterable_in_grid' => false, 'is_searchable_in_grid' => true], 'city' => ['is_used_in_grid' => true, 'is_visible_in_grid' => false, 'is_filterable_in_grid' => false, 'is_searchable_in_grid' => true], 'country_id' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => false], 'region' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => false, 'is_searchable_in_grid' => true], 'region_id' => ['is_used_in_grid' => true, 'is_visible_in_grid' => false, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => false], 'postcode' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => true], 'telephone' => ['is_used_in_grid' => true, 'is_visible_in_grid' => true, 'is_filterable_in_grid' => true, 'is_searchable_in_grid' => true], 'fax' => ['is_used_in_grid' => true, 'is_visible_in_grid' => false, 'is_filterable_in_grid' => false, 'is_searchable_in_grid' => true]]]; $this->upgradeAttributes($entityAttributes, $customerSetup); } if (version_compare($context->getVersion(), '2.0.2') < 0) { $entityTypeId = $customerSetup->getEntityTypeId(Customer::ENTITY); $attributeId = $customerSetup->getAttributeId($entityTypeId, 'gender'); $option = ['attribute_id' => $attributeId, 'values' => [3 => 'Not Specified']]; $customerSetup->addAttributeOption($option); } if (version_compare($context->getVersion(), '2.0.3', '<')) { $entityAttributes = ['customer_address' => ['region_id' => ['is_used_in_grid' => false, 'is_visible_in_grid' => false, 'is_filterable_in_grid' => false, 'is_searchable_in_grid' => false], 'firstname' => ['is_used_in_grid' => true, 'is_visible_in_grid' => false, 'is_filterable_in_grid' => false, 'is_searchable_in_grid' => true], 'lastname' => ['is_used_in_grid' => true, 'is_visible_in_grid' => false, 'is_filterable_in_grid' => false, 'is_searchable_in_grid' => true]]]; $this->upgradeAttributes($entityAttributes, $customerSetup); } if (version_compare($context->getVersion(), '2.0.4', '<')) { $customerSetup->addAttribute(Customer::ENTITY, 'updated_at', ['type' => 'static', 'label' => 'Updated At', 'input' => 'date', 'required' => false, 'sort_order' => 87, 'visible' => false, 'system' => false]); } if (version_compare($context->getVersion(), '2.0.5', '<')) { $this->upgradeHash($setup); $entityAttributes = ['customer_address' => ['fax' => ['is_visible' => false, 'is_system' => false]]]; $this->upgradeAttributes($entityAttributes, $customerSetup); } $indexer = $this->indexerRegistry->get(Customer::CUSTOMER_GRID_INDEXER_ID); $indexer->reindexAll(); $this->eavConfig->clear(); $setup->endSetup(); }
/** * {@inheritdoc} * @SuppressWarnings(PHPMD.NPathComplexity) */ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { $setup->startSetup(); /** @var CustomerSetup $customerSetup */ $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]); if (version_compare($context->getVersion(), '2.0.6', '<')) { $this->upgradeVersionTwoZeroSix($customerSetup); } if (version_compare($context->getVersion(), '2.0.1', '<')) { $this->upgradeVersionTwoZeroOne($customerSetup); } if (version_compare($context->getVersion(), '2.0.2') < 0) { $this->upgradeVersionTwoZeroTwo($customerSetup); } if (version_compare($context->getVersion(), '2.0.3', '<')) { $this->upgradeVersionTwoZeroThree($customerSetup); } if (version_compare($context->getVersion(), '2.0.4', '<')) { $this->upgradeVersionTwoZeroFour($customerSetup); } if (version_compare($context->getVersion(), '2.0.5', '<')) { $this->upgradeVersionTwoZeroFive($customerSetup, $setup); } if (version_compare($context->getVersion(), '2.0.6', '<')) { $setup->getConnection()->delete($setup->getTable('customer_form_attribute'), ['form_code = ?' => 'checkout_register']); } if (version_compare($context->getVersion(), '2.0.7', '<')) { $this->upgradeVersionTwoZeroSeven($customerSetup); $this->upgradeCustomerPasswordResetlinkExpirationPeriodConfig($setup); } $indexer = $this->indexerRegistry->get(Customer::CUSTOMER_GRID_INDEXER_ID); $indexer->reindexAll(); $this->eavConfig->clear(); $setup->endSetup(); }
/** * Installs DB schema for a module * * @param ModuleDataSetupInterface $setup * @param ModuleContextInterface $context * @return void */ 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, 'used_in_forms', ['adminhtml_customer']]); $setup->endSetup(); }
/** * Upgrades data for a module * * @param ModuleDataSetupInterface $setup * @param ModuleContextInterface $context * @return void */ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { $dbVersion = $context->getVersion(); if (version_compare($dbVersion, '0.1.0', '<')) { /** @var CustomerSetup $customerSetup */ $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]); $customerSetup->addAttribute(self::CUSTOMER_EAV_ENTITY_TYPE, self::OPENPAY_CUSTOMER_ID_CUSTOM_ATTRIBUTE, ['label' => 'Openpay Customer ID', 'required' => 0, 'system' => 0, 'position' => 100]); $customerSetup->getEavConfig()->getAttribute('customer', self::OPENPAY_CUSTOMER_ID_CUSTOM_ATTRIBUTE)->setData('used_in_forms', ['adminhtml_customer'])->save(); } }
/** * Installs DB schema for a module * * @param ModuleDataSetupInterface $setup * @param ModuleContextInterface $context * @return void */ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { $setup->startSetup(); /** @var CustomerSetup $customerSetup */ $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]); // Add new customer attribute $customerSetup->addAttribute(Customer::ENTITY, 'customer_number', ['label' => 'Customer Number', 'input' => 'text', 'required' => false, 'sort_order' => 10, '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', 'customer_number'); $attribute->setData('used_in_forms', ['adminhtml_customer']); $attribute->save(); $setup->endSetup(); }
/** * {@inheritdoc} * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { $setup->startSetup(); if ($context->getVersion() && version_compare($context->getVersion(), '0.0.2') < 0) { $admin = $this->storeManager->getStore('admin')->getId(); $default = $this->storeManager->getStore('default')->getId(); $catalogSetup = $this->catalogSetupFactory->create(['setup' => $setup]); $catalogSetup->addAttribute(Product::ENTITY, 'example_multiselect', ['label' => 'Example Multi-Select', 'input' => 'multiselect', 'visible_on_front' => 1, 'backend' => ArrayBackend::class, 'required' => 0, 'global' => CatalogAttribute::SCOPE_STORE, 'option' => ['order' => ['option1' => 10, 'options2' => 20], 'value' => ['option1' => [$admin => 'Admin Label 1', $default => 'Frontend Label 1'], 'option2' => [$admin => 'Admin Label 2', $default => 'Frontend Label 2']]]]); } if ($context->getVersion() && version_compare($context->getVersion(), '0.0.3') < 0) { $catalogSetup = $this->catalogSetupFactory->create(['setup' => $setup]); $catalogSetup->updateAttribute(Product::ENTITY, 'example_multiselect', ['frontend_model' => \Training\Orm\Entity\Attribute\Frontend\HtmlList::class, 'is_html_allowed_on_front' => 1]); } if ($context->getVersion() && version_compare($context->getVersion(), '0.0.4') < 0) { $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]); $customerSetup->addAttribute(Customer::ENTITY, 'priority', ['label' => 'Priority', 'type' => 'int', 'input' => 'select', 'source' => \Training\Orm\Entity\Attribute\Source\CustomerPriority::class, 'required' => 0, 'system' => 0, 'position' => 100]); $customerSetup->getEavConfig()->getAttribute('customer', 'priority')->setData('used_in_forms', ['adminhtml_customer'])->save(); } if ($context->getVersion() && version_compare($context->getVersion(), '0.0.5') < 0) { $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]); $customerSetup->getEavConfig()->getAttribute('customer', 'priority')->setData('used_in_forms', ['adminhtml_customer', 'customer_account_create', 'customer_account_edit'])->save(); } $setup->endSetup(); }
/** * {@inheritdoc} * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { $installer = $setup; $installer->startSetup(); $catalogSetup = $this->categorySetupFactory->create(['setup' => $setup]); /* ------ shipperhq_shipping_fee -------- */ $catalogSetup->addAttribute(\Magento\Catalog\Model\Product::ENTITY, 'shipperhq_shipping_fee', ['type' => 'decimal', 'backend' => 'Magento\\Catalog\\Model\\Product\\Attribute\\Backend\\Price', 'input' => 'price', 'label' => 'Shipping Fee', 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'visible' => true, 'required' => false, 'visible_on_front' => false, 'is_html_allowed_on_front' => false, 'searchable' => false, 'filterable' => false, 'comparable' => false, 'is_configurable' => false, 'unique' => false, 'user_defined' => true, 'used_in_product_listing' => false]); /* ------ shipperhq_handling_fee -------- */ $catalogSetup->addAttribute(\Magento\Catalog\Model\Product::ENTITY, 'shipperhq_handling_fee', ['type' => 'decimal', 'backend' => 'Magento\\Catalog\\Model\\Product\\Attribute\\Backend\\Price', 'input' => 'price', 'label' => 'Handling Fee', 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'visible' => true, 'required' => false, 'visible_on_front' => false, 'is_html_allowed_on_front' => false, 'searchable' => false, 'filterable' => false, 'comparable' => false, 'is_configurable' => false, 'unique' => false, 'user_defined' => true, 'used_in_product_listing' => false]); /* ------ shipperhq_volume_weight -------- */ $catalogSetup->addAttribute(\Magento\Catalog\Model\Product::ENTITY, 'shipperhq_volume_weight', ['type' => 'varchar', 'input' => 'text', 'label' => 'Volume Weight', 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'visible' => true, 'required' => false, 'visible_on_front' => false, 'is_html_allowed_on_front' => false, 'searchable' => false, 'filterable' => false, 'comparable' => false, 'is_configurable' => false, 'unique' => false, 'user_defined' => true, 'used_in_product_listing' => false, 'note' => 'This value is only used in conjunction with shipping filters']); /* ------ shipperhq_declared_value -------- */ $catalogSetup->addAttribute(\Magento\Catalog\Model\Product::ENTITY, 'shipperhq_declared_value', ['type' => 'decimal', 'backend' => 'Magento\\Catalog\\Model\\Product\\Attribute\\Backend\\Price', 'input' => 'price', 'label' => 'Declared Value', 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'visible' => true, 'required' => false, 'visible_on_front' => false, 'is_html_allowed_on_front' => false, 'searchable' => false, 'filterable' => false, 'comparable' => false, 'is_configurable' => false, 'unique' => false, 'user_defined' => true, 'used_in_product_listing' => false, 'note' => 'The deemed cost of this product for customs & insurance purposes']); /* ------ ship_separately -------- */ $catalogSetup->addAttribute(\Magento\Catalog\Model\Product::ENTITY, 'ship_separately', ['type' => 'int', 'input' => 'boolean', 'label' => 'Ship Separately', 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'visible' => true, 'required' => false, 'visible_on_front' => false, 'is_html_allowed_on_front' => false, 'searchable' => false, 'filterable' => false, 'comparable' => false, 'is_configurable' => false, 'unique' => false, 'user_defined' => true, 'used_in_product_listing' => false]); /* ------ shipperhq_dim_group -------- */ $catalogSetup->addAttribute(\Magento\Catalog\Model\Product::ENTITY, 'shipperhq_dim_group', ['type' => 'int', 'backend' => 'Magento\\Eav\\Model\\Entity\\Attribute\\Backend\\ArrayBackend', 'frontend' => '', 'label' => 'ShipperHQ Dimensional Rule Group', 'input' => 'select', 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'visible' => true, 'required' => false, 'visible_on_front' => false, 'is_html_allowed_on_front' => false, 'searchable' => false, 'filterable' => false, 'comparable' => false, 'is_configurable' => false, 'unique' => false, 'user_defined' => true, 'used_in_product_listing' => false]); /* ------ ship_length -------- */ $catalogSetup->addAttribute(\Magento\Catalog\Model\Product::ENTITY, 'ship_length', ['type' => 'decimal', 'input' => 'text', 'label' => 'Dimension Length', 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'visible' => true, 'required' => false, 'visible_on_front' => false, 'is_html_allowed_on_front' => false, 'searchable' => false, 'filterable' => false, 'comparable' => false, 'is_configurable' => false, 'unique' => false, 'user_defined' => true, 'used_in_product_listing' => false]); /* ------ ship_width -------- */ $catalogSetup->addAttribute(\Magento\Catalog\Model\Product::ENTITY, 'ship_width', ['type' => 'decimal', 'input' => 'text', 'label' => 'Dimension Width', 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'visible' => true, 'required' => false, 'visible_on_front' => false, 'is_html_allowed_on_front' => false, 'searchable' => false, 'filterable' => false, 'comparable' => false, 'is_configurable' => false, 'unique' => false, 'user_defined' => true, 'used_in_product_listing' => false]); /* ------ ship_height -------- */ $catalogSetup->addAttribute(\Magento\Catalog\Model\Product::ENTITY, 'ship_height', ['type' => 'decimal', 'input' => 'text', 'label' => 'Dimension Height', 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'visible' => true, 'required' => false, 'visible_on_front' => false, 'is_html_allowed_on_front' => false, 'searchable' => false, 'filterable' => false, 'comparable' => false, 'is_configurable' => false, 'unique' => false, 'user_defined' => true, 'used_in_product_listing' => false]); /* ------ shipperhq_poss_boxes -------- */ $catalogSetup->addAttribute(\Magento\Catalog\Model\Product::ENTITY, 'shipperhq_poss_boxes', ['type' => 'text', 'backend' => 'Magento\\Eav\\Model\\Entity\\Attribute\\Backend\\ArrayBackend', 'input' => 'multiselect', 'label' => 'Possible Packing Boxes', 'global' => false, 'visible' => true, 'required' => false, 'visible_on_front' => false, 'is_html_allowed_on_front' => false, 'searchable' => false, 'filterable' => false, 'comparable' => false, 'is_configurable' => false, 'unique' => false, 'user_defined' => true, 'used_in_product_listing' => false]); /* ------ shipperhq_malleable_product -------- */ $catalogSetup->addAttribute(\Magento\Catalog\Model\Product::ENTITY, 'shipperhq_malleable_product', ['type' => 'int', 'input' => 'boolean', 'label' => 'Malleable Product', 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'visible' => true, 'required' => false, 'visible_on_front' => false, 'is_html_allowed_on_front' => false, 'searchable' => false, 'filterable' => false, 'comparable' => false, 'is_configurable' => false, 'unique' => false, 'user_defined' => true, 'used_in_product_listing' => false, 'note' => 'Ignore if unsure. Indicates the product dimensions can be adjusted to fit box']); /* ------ shipperhq_master_boxes -------- */ $catalogSetup->addAttribute(\Magento\Catalog\Model\Product::ENTITY, 'shipperhq_master_boxes', ['type' => 'text', 'backend' => 'Magento\\Eav\\Model\\Entity\\Attribute\\Backend\\ArrayBackend', 'input' => 'multiselect', 'label' => 'Master Packing Boxes', 'global' => false, 'visible' => true, 'required' => false, 'visible_on_front' => false, 'is_html_allowed_on_front' => false, 'searchable' => false, 'filterable' => false, 'comparable' => false, 'is_configurable' => false, 'unique' => false, 'user_defined' => true, 'used_in_product_listing' => false]); $entityTypeId = $catalogSetup->getEntityTypeId(\Magento\Catalog\Model\Product::ENTITY); $attributeSetArr = $catalogSetup->getAllAttributeSetIds($entityTypeId); $dimAttributeCodes = ['ship_separately' => '2', 'shipperhq_dim_group' => '1', 'ship_length' => '10', 'ship_width' => '11', 'ship_height' => '12', 'shipperhq_poss_boxes' => '20']; foreach ($attributeSetArr as $attributeSetId) { $catalogSetup->addAttributeGroup($entityTypeId, $attributeSetId, 'Dimensional Shipping', '100'); $attributeGroupId = $catalogSetup->getAttributeGroupId($entityTypeId, $attributeSetId, 'Dimensional Shipping'); foreach ($dimAttributeCodes as $code => $sort) { $attributeId = $catalogSetup->getAttributeId($entityTypeId, $code); $catalogSetup->addAttributeToGroup($entityTypeId, $attributeSetId, $attributeGroupId, $attributeId, $sort); } } $catalogSetup->addAttribute(\Magento\Catalog\Model\Product::ENTITY, 'shipperhq_availability_date', ['type' => 'datetime', 'backend' => 'Magento\\Eav\\Model\\Entity\\Attribute\\Backend\\Datetime', 'input' => 'date', 'label' => 'Availability Date', 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'visible' => true, 'required' => false, 'visible_on_front' => false, 'is_html_allowed_on_front' => false, 'searchable' => false, 'filterable' => false, 'comparable' => false, 'is_configurable' => false, 'unique' => false, 'user_defined' => true, 'used_in_product_listing' => false]); /** @var \Magento\Quote\Setup\QuoteSetup $quoteSetup */ $quoteSetup = $this->quoteSetupFactory->create(['setup' => $setup]); $salesSetup = $this->salesSetupFactory->create(['setup' => $setup]); $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]); $destinationTypeAttr = ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'visible' => false, 'required' => false, 'comment' => 'ShipperHQ Address Type']; $quoteSetup->addAttribute('quote_address', 'destination_type', $destinationTypeAttr); $salesSetup->addAttribute('order', 'destination_type', $destinationTypeAttr); $destinationTypeAddressAttr = ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'label' => 'Address Type', 'system' => 0, 'required' => false, 'position' => 100, 'comment' => 'ShipperHQ Address Type']; $customerSetup->addAttribute('customer_address', 'destination_type', $destinationTypeAddressAttr); $addressValiationStatus = ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'visible' => false, 'required' => false, 'comment' => 'ShipperHQ Address Validation Status']; $quoteSetup->addAttribute('quote_address', 'validation_status', $addressValiationStatus); $salesSetup->addAttribute('order', 'validation_status', $addressValiationStatus); $validationStatusAddressAttr = ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'label' => 'Address Validation', 'system' => 0, 'required' => false, 'position' => 101, 'comment' => 'ShipperHQ Address Validation Status']; $customerSetup->addAttribute('customer_address', 'validation_status', $validationStatusAddressAttr); // add attribute to form /** @var $attribute */ $attribute = $customerSetup->getEavConfig()->getAttribute('customer_address', 'validation_status'); $attribute->setData('used_in_forms', ['adminhtml_customer_address']); $attribute->save(); $attribute = $customerSetup->getEavConfig()->getAttribute('customer_address', 'destination_type'); $attribute->setData('used_in_forms', ['adminhtml_customer_address']); $attribute->save(); //1.0.7 $dispatchDateAttr = ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_DATE, 'visible' => false, 'required' => false, 'comment' => 'ShipperHQ Address Type']; $quoteSetup->addAttribute('quote_address_rate', 'shq_dispatch_date', $dispatchDateAttr); $deliveryDateAttr = ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_DATE, 'visible' => false, 'required' => false, 'comment' => 'ShipperHQ Address Type']; $quoteSetup->addAttribute('quote_address_rate', 'shq_delivery_date', $deliveryDateAttr); $installer->endSetup(); }
/** * {@inheritdoc} */ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { /** @var CustomerSetup $customerSetup */ $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]); $customerEntity = $customerSetup->getEavConfig()->getEntityType('customer'); $attributeSetId = $customerEntity->getDefaultAttributeSetId(); /** @var $attributeSet AttributeSet */ $attributeSet = $this->attributeSetFactory->create(); $attributeGroupId = $attributeSet->getDefaultGroupId($attributeSetId); $customerSetup->addAttribute(Customer::ENTITY, 'magento_username', ['type' => 'varchar', 'label' => 'Magento Username', 'input' => 'text', 'required' => false, 'visible' => true, 'user_defined' => true, 'sort_order' => 1000, 'position' => 1000, 'system' => 0]); $attribute = $customerSetup->getEavConfig()->getAttribute(Customer::ENTITY, 'magento_username')->addData(['attribute_set_id' => $attributeSetId, 'attribute_group_id' => $attributeGroupId, 'used_in_forms' => ['adminhtml_customer']]); $attribute->save(); }