Example #1
0
 /**
  * {@inheritdoc}
  */
 public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     /**
      * Add 'gift_message_id' attributes for entities
      */
     $options = ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, 'visible' => false, 'required' => false];
     $entities = ['quote', 'quote_address', 'quote_item', 'quote_address_item'];
     foreach ($entities as $entity) {
         /** @var \Magento\Quote\Setup\QuoteSetup $quoteSetup */
         $quoteSetup = $this->quoteSetupFactory->create(['setup' => $setup]);
         $quoteSetup->addAttribute($entity, 'gift_message_id', $options);
     }
     /** @var \Magento\Sales\Setup\SalesSetup $salesSetup */
     $salesSetup = $this->salesSetupFactory->create(['setup' => $setup]);
     $salesSetup->addAttribute('order', 'gift_message_id', $options);
     $salesSetup->addAttribute('order_item', 'gift_message_id', $options);
     /**
      * Add 'gift_message_available' attributes for entities
      */
     $salesSetup->addAttribute('order_item', 'gift_message_available', $options);
     /** @var \Magento\Catalog\Setup\CategorySetup $catalogSetup */
     $catalogSetup = $this->categorySetupFactory->create(['setup' => $setup]);
     $catalogSetup->addAttribute(\Magento\Catalog\Model\Product::ENTITY, 'gift_message_available', ['group' => 'Gift Options', 'backend' => 'Magento\\Catalog\\Model\\Product\\Attribute\\Backend\\Boolean', 'frontend' => '', 'label' => 'Allow Gift Message', 'input' => 'select', 'class' => '', 'source' => 'Magento\\Catalog\\Model\\Product\\Attribute\\Source\\Boolean', 'global' => true, 'visible' => true, 'required' => false, 'user_defined' => false, 'default' => '', 'apply_to' => '', 'input_renderer' => 'Magento\\GiftMessage\\Block\\Adminhtml\\Product\\Helper\\Form\\Config', 'visible_on_front' => false, 'is_used_in_grid' => true, 'is_visible_in_grid' => false, 'is_filterable_in_grid' => false]);
     $groupName = 'Autosettings';
     $entityTypeId = $catalogSetup->getEntityTypeId(\Magento\Catalog\Model\Product::ENTITY);
     $attributeSetId = $catalogSetup->getAttributeSetId($entityTypeId, 'Default');
     $attribute = $catalogSetup->getAttribute($entityTypeId, 'gift_message_available');
     if ($attribute) {
         $catalogSetup->addAttributeToGroup($entityTypeId, $attributeSetId, $groupName, $attribute['attribute_id'], 60);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     /**
      * Prepare database for install
      */
     $setup->startSetup();
     $quoteInstaller = $this->quoteSetupFactory->create(['resourceName' => 'quote_setup', 'setup' => $setup]);
     $salesInstaller = $this->salesSetupFactory->create(['resourceName' => 'sales_setup', 'setup' => $setup]);
     /**
      * Add paypal attributes to the:
      *  - sales/flat_quote_payment_item table
      *  - sales/flat_order table
      */
     $quoteInstaller->addAttribute('quote_payment', 'paypal_payer_id', []);
     $quoteInstaller->addAttribute('quote_payment', 'paypal_payer_status', []);
     $quoteInstaller->addAttribute('quote_payment', 'paypal_correlation_id', []);
     $salesInstaller->addAttribute('order', 'paypal_ipn_customer_notified', ['type' => 'int', 'visible' => false, 'default' => 0]);
     $data = [];
     $statuses = ['pending_paypal' => __('Pending PayPal'), 'paypal_reversed' => __('PayPal Reversed'), 'paypal_canceled_reversal' => __('PayPal Canceled Reversal')];
     foreach ($statuses as $code => $info) {
         $data[] = ['status' => $code, 'label' => $info];
     }
     $setup->getConnection()->insertArray($setup->getTable('sales_order_status'), ['status', 'label'], $data);
     /**
      * Prepare database after install
      */
     $setup->endSetup();
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     /** @var QuoteSetup $quoteSetup */
     $quoteSetup = $this->quoteSetupFactory->create();
     /**
      * Install eav entity types to the eav/entity_type table
      */
     $attributes = ['vat_id' => ['type' => Table::TYPE_TEXT], 'vat_is_valid' => ['type' => Table::TYPE_SMALLINT], 'vat_request_id' => ['type' => Table::TYPE_TEXT], 'vat_request_date' => ['type' => Table::TYPE_TEXT], 'vat_request_success' => ['type' => Table::TYPE_SMALLINT]];
     foreach ($attributes as $attributeCode => $attributeParams) {
         $quoteSetup->addAttribute('quote_address', $attributeCode, $attributeParams);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     /** @var QuoteSetup $quoteSetup */
     $quoteSetup = $this->quoteSetupFactory->create(['setup' => $setup]);
     $quoteSetup->addAttribute('quote_item', 'weee_tax_applied', ['type' => 'text']);
     $quoteSetup->addAttribute('quote_item', 'weee_tax_applied_amount', ['type' => 'decimal']);
     $quoteSetup->addAttribute('quote_item', 'weee_tax_applied_row_amount', ['type' => 'decimal']);
     $quoteSetup->addAttribute('quote_item', 'weee_tax_disposition', ['type' => 'decimal']);
     $quoteSetup->addAttribute('quote_item', 'weee_tax_row_disposition', ['type' => 'decimal']);
     $quoteSetup->addAttribute('quote_item', 'base_weee_tax_applied_amount', ['type' => 'decimal']);
     $quoteSetup->addAttribute('quote_item', 'base_weee_tax_applied_row_amnt', ['type' => 'decimal']);
     $quoteSetup->addAttribute('quote_item', 'base_weee_tax_disposition', ['type' => 'decimal']);
     $quoteSetup->addAttribute('quote_item', 'base_weee_tax_row_disposition', ['type' => 'decimal']);
     /** @var SalesSetup $salesSetup */
     $salesSetup = $this->salesSetupFactory->create(['setup' => $setup]);
     $salesSetup->addAttribute('order_item', 'weee_tax_applied', ['type' => 'text']);
     $salesSetup->addAttribute('order_item', 'weee_tax_applied_amount', ['type' => 'decimal']);
     $salesSetup->addAttribute('order_item', 'weee_tax_applied_row_amount', ['type' => 'decimal']);
     $salesSetup->addAttribute('order_item', 'weee_tax_disposition', ['type' => 'decimal']);
     $salesSetup->addAttribute('order_item', 'weee_tax_row_disposition', ['type' => 'decimal']);
     $salesSetup->addAttribute('order_item', 'base_weee_tax_applied_amount', ['type' => 'decimal']);
     $salesSetup->addAttribute('order_item', 'base_weee_tax_applied_row_amnt', ['type' => 'decimal']);
     $salesSetup->addAttribute('order_item', 'base_weee_tax_disposition', ['type' => 'decimal']);
     $salesSetup->addAttribute('order_item', 'base_weee_tax_row_disposition', ['type' => 'decimal']);
     $salesSetup->addAttribute('invoice_item', 'weee_tax_applied', ['type' => 'text']);
     $salesSetup->addAttribute('invoice_item', 'weee_tax_applied_amount', ['type' => 'decimal']);
     $salesSetup->addAttribute('invoice_item', 'weee_tax_applied_row_amount', ['type' => 'decimal']);
     $salesSetup->addAttribute('invoice_item', 'weee_tax_disposition', ['type' => 'decimal']);
     $salesSetup->addAttribute('invoice_item', 'weee_tax_row_disposition', ['type' => 'decimal']);
     $salesSetup->addAttribute('invoice_item', 'base_weee_tax_applied_amount', ['type' => 'decimal']);
     $salesSetup->addAttribute('invoice_item', 'base_weee_tax_applied_row_amnt', ['type' => 'decimal']);
     $salesSetup->addAttribute('invoice_item', 'base_weee_tax_disposition', ['type' => 'decimal']);
     $salesSetup->addAttribute('invoice_item', 'base_weee_tax_row_disposition', ['type' => 'decimal']);
     $salesSetup->addAttribute('creditmemo_item', 'weee_tax_applied', ['type' => 'text']);
     $salesSetup->addAttribute('creditmemo_item', 'weee_tax_applied_amount', ['type' => 'decimal']);
     $salesSetup->addAttribute('creditmemo_item', 'weee_tax_applied_row_amount', ['type' => 'decimal']);
     $salesSetup->addAttribute('creditmemo_item', 'weee_tax_disposition', ['type' => 'decimal']);
     $salesSetup->addAttribute('creditmemo_item', 'weee_tax_row_disposition', ['type' => 'decimal']);
     $salesSetup->addAttribute('creditmemo_item', 'base_weee_tax_applied_amount', ['type' => 'decimal']);
     $salesSetup->addAttribute('creditmemo_item', 'base_weee_tax_applied_row_amnt', ['type' => 'decimal']);
     $salesSetup->addAttribute('creditmemo_item', 'base_weee_tax_disposition', ['type' => 'decimal']);
     $salesSetup->addAttribute('creditmemo_item', 'base_weee_tax_row_disposition', ['type' => 'decimal']);
 }
Example #5
0
 /**
  * {@inheritdoc}
  */
 public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     $varcharOptions = ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'visible' => true, 'required' => false];
     $booleanOptions = ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_BOOLEAN, 'visible' => true, 'required' => false];
     /** @var \Magento\Quote\Setup\QuoteSetup $quoteSetup */
     $quoteSetup = $this->_quoteSetupFactory->create(['setup' => $setup]);
     $quoteSetup->addAttribute('quote', 'vatpername', $varcharOptions);
     $quoteSetup->addAttribute('quote', 'vatcomment', $varcharOptions);
     $quoteSetup->addAttribute('quote', 'vatdeclare', $booleanOptions);
     $quoteSetup->addAttribute('quote_item', 'vat_exempt', $booleanOptions);
     /** @var \Magento\Sales\Setup\SalesSetup $salesSetup */
     $salesSetup = $this->_salesSetupFactory->create(['setup' => $setup]);
     $salesSetup->addAttribute('order', 'vatpername', $varcharOptions);
     $salesSetup->addAttribute('order', 'vatcomment', $varcharOptions);
     $salesSetup->addAttribute('order', 'vatdeclare', $booleanOptions);
     $salesSetup->addAttribute('order_item', 'vat_exempt', $booleanOptions);
     /** @var Magento\Eav\Setup\EavSetupFactory $eavSetup */
     $eavSetup = $this->_eavSetupFactory->create(['setup' => $setup]);
     $eavSetup->addAttribute(\Magento\Catalog\Model\Product::ENTITY, 'vat_exempt', ['group' => 'General', 'type' => 'int', 'backend' => '', 'frontend' => '', 'label' => 'Vat Exempt', 'input' => 'select', 'class' => '', 'source' => 'Magento\\Eav\\Model\\Entity\\Attribute\\Source\\Boolean', 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'visible' => true, 'required' => false, 'user_defined' => true, 'default' => '', 'searchable' => false, 'filterable' => false, 'comparable' => false, 'visible_on_front' => true, 'unique' => false, 'apply_to' => 'simple,configurable,virtual', 'is_configurable' => false]);
 }
Example #6
0
 /**
  * {@inheritdoc}
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
 {
     $installer = $setup;
     $installer->startSetup();
     $catalogSetup = $this->categorySetupFactory->create(['setup' => $setup]);
     /* ------ shipperhq_shipping_group -------- */
     $catalogSetup->addAttribute(\Magento\Catalog\Model\Product::ENTITY, 'shipperhq_shipping_group', ['type' => 'text', 'backend' => 'Magento\\Eav\\Model\\Entity\\Attribute\\Backend\\ArrayBackend', 'input' => 'multiselect', 'label' => 'Shipping Group', '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_warehouse -------- */
     $catalogSetup->addAttribute(\Magento\Catalog\Model\Product::ENTITY, 'shipperhq_warehouse', ['type' => 'text', 'backend' => 'Magento\\Eav\\Model\\Entity\\Attribute\\Backend\\ArrayBackend', 'input' => 'multiselect', 'label' => 'Origin', '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);
     $stdAttributeCodes = ['shipperhq_shipping_group' => '1', 'shipperhq_warehouse' => '10'];
     foreach ($attributeSetArr as $attributeSetId) {
         $catalogSetup->addAttributeGroup($entityTypeId, $attributeSetId, 'Shipping', '99');
         $attributeGroupId = $catalogSetup->getAttributeGroupId($entityTypeId, $attributeSetId, 'Shipping');
         foreach ($stdAttributeCodes as $code => $sort) {
             $attributeId = $catalogSetup->getAttributeId($entityTypeId, $code);
             $catalogSetup->addAttributeToGroup($entityTypeId, $attributeSetId, $attributeGroupId, $attributeId, $sort);
         }
     }
     /** @var \Magento\Quote\Setup\QuoteSetup $quoteSetup */
     $quoteSetup = $this->quoteSetupFactory->create(['setup' => $setup]);
     $salesSetup = $this->salesSetupFactory->create(['setup' => $setup]);
     $carrier_type = ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'visible' => false, 'required' => false, 'comment' => 'ShipperHQ Carrier Type'];
     $entities = ['quote_address', 'quote_address_rate'];
     foreach ($entities as $entity) {
         $quoteSetup->addAttribute($entity, 'carrier_type', $carrier_type);
     }
     $salesSetup->addAttribute('order', 'carrier_type', $carrier_type);
     $carrier_id = ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'visible' => false, 'required' => false, 'comment' => 'ShipperHQ Carrier ID'];
     $entities = ['quote_address_rate', 'quote_address'];
     foreach ($entities as $entity) {
         $quoteSetup->addAttribute($entity, 'carrier_id', $carrier_id);
     }
     $salesSetup->addAttribute('order', 'carrier_id', $carrier_id);
     $carrier_group_id = ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'visible' => false, 'required' => false, 'comment' => 'Carrier Group ID'];
     $entities = ['quote_address_rate', 'quote_item', 'quote_address_item'];
     foreach ($entities as $entity) {
         $quoteSetup->addAttribute($entity, 'carriergroup_id', $carrier_group_id);
     }
     $salesSetup->addAttribute('order_item', 'carriergroup_id', $carrier_group_id);
     $carrier_group = ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'visible' => false, 'required' => false, 'comment' => 'ShipperHQ Carrier Group'];
     $entities = ['quote_address_rate', 'quote_item', 'quote_address_item'];
     foreach ($entities as $entity) {
         $quoteSetup->addAttribute($entity, 'carriergroup', $carrier_group);
     }
     $salesSetup->addAttribute('order_item', 'carriergroup', $carrier_group);
     $carrierGroupDetails = ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'visible' => false, 'required' => false, 'comment' => 'ShipperHQ Carrier Group Details'];
     $entities = ['quote_address_rate', 'quote_address'];
     foreach ($entities as $entity) {
         $quoteSetup->addAttribute($entity, 'carriergroup_shipping_details', $carrierGroupDetails);
     }
     $salesSetup->addAttribute('order', 'carriergroup_shipping_details', $carrierGroupDetails);
     $isCheckout = ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, 'visible' => false, 'required' => true, 'default' => 0, 'comment' => 'ShipperHQ Checkout Flag'];
     $quoteSetup->addAttribute('quote_address', 'is_checkout', $isCheckout);
     $splitRates = ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, 'visible' => false, 'required' => true, 'default' => 0, 'comment' => 'ShipperHQ Split Rates Flag'];
     $quoteSetup->addAttribute('quote_address', 'split_rates', $splitRates);
     $displayMerged = ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, 'visible' => false, 'required' => true, 'default' => 1, 'comment' => 'ShipperHQ Checkout Display Type'];
     $quoteSetup->addAttribute('quote_address', 'checkout_display_merged', $displayMerged);
     $carriergroupHtml = ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'visible' => false, 'required' => false, 'comment' => 'ShipperHQ Carrier Group HTML'];
     $quoteSetup->addAttribute('quote_address', 'carriergroup_shipping_html', $carriergroupHtml);
     $salesSetup->addAttribute('order', 'carriergroup_shipping_html', $carriergroupHtml);
     $carriergroupShipping = ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'visible' => false, 'required' => false, 'comment' => 'ShipperHQ Shipping Description'];
     $entities = ['quote_item', 'quote_address_item'];
     foreach ($entities as $entity) {
         $quoteSetup->addAttribute($entity, 'carriergroup_shipping', $carriergroupShipping);
     }
     $salesSetup->addAttribute('order_item', 'carriergroup_shipping', $carriergroupShipping);
     $this->configStorageWriter->save('carriers/shipper/ignore_empty_zip', 1);
 }
Example #7
0
 /**
  * {@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();
 }