public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { $this->installer = $setup; $this->installer->startSetup(); try { $this->installGeneral(); $this->installEbay(); $this->installAmazon(); } catch (\Exception $exception) { return; } $this->installer->endSetup(); $this->getConnection()->insert($this->getFullTableName('setup'), ['version_from' => NULL, 'version_to' => $this->getConfigVersion(), 'is_completed' => 1, 'update_date' => $this->helperFactory->getObject('Data')->getCurrentGmtDate(), 'create_date' => $this->helperFactory->getObject('Data')->getCurrentGmtDate()]); $this->helperFactory->getObject('Module\\Maintenance\\Setup')->disable(); }
/** * {@inheritdoc} */ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { $setup->startSetup(); $indexer = $this->indexerRegistry->get(Config::DESIGN_CONFIG_GRID_INDEXER_ID); $indexer->reindexAll(); $setup->endSetup(); }
/** * {@inheritdoc} */ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { $setup->startSetup(); /* * Report Event Types default data */ $eventTypeData = [['event_type_id' => \Magento\Reports\Model\Event::EVENT_PRODUCT_VIEW, 'event_name' => 'catalog_product_view'], ['event_type_id' => \Magento\Reports\Model\Event::EVENT_PRODUCT_SEND, 'event_name' => 'sendfriend_product'], ['event_type_id' => \Magento\Reports\Model\Event::EVENT_PRODUCT_COMPARE, 'event_name' => 'catalog_product_compare_add_product'], ['event_type_id' => \Magento\Reports\Model\Event::EVENT_PRODUCT_TO_CART, 'event_name' => 'checkout_cart_add_product'], ['event_type_id' => \Magento\Reports\Model\Event::EVENT_PRODUCT_TO_WISHLIST, 'event_name' => 'wishlist_add_product'], ['event_type_id' => \Magento\Reports\Model\Event::EVENT_WISHLIST_SHARE, 'event_name' => 'wishlist_share']]; foreach ($eventTypeData as $row) { $setup->getConnection()->insertForce($setup->getTable('report_event_types'), $row); } /** * Prepare database after data upgrade */ $setup->endSetup(); /** * Cms Page with 'home' identifier page modification for report pages */ /** @var $cms \Magento\Cms\Model\Page */ $cms = $this->pageFactory->create(); $cms->load('home', 'identifier'); $reportLayoutUpdate = '<!-- <referenceContainer name="right"> <action method="unsetChild"><argument name="alias" xsi:type="string">right.reports.product.viewed</argument></action> <action method="unsetChild"><argument name="alias" xsi:type="string">right.reports.product.compared</argument></action> </referenceContainer>-->'; /* * Merge and save old layout update data with report layout data */ $cms->setLayoutUpdateXml($cms->getLayoutUpdateXml() . $reportLayoutUpdate)->save(); }
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { $setup->startSetup(); $salesDepartment = $this->departmentFactory->create(); $salesDepartment->setName('Sales'); $salesDepartment->save(); $employee = $this->employeeFactory->create(); $employee->setDepartmentId($salesDepartment->getId()); $employee->setEmail('*****@*****.**'); $employee->setFirstName('John'); $employee->setLastName('Doe'); $employee->setServiceYears(3); $employee->setDob('1983-03-28'); $employee->setSalary(3800.0); $employee->setVatNumber('GB123456789'); $employee->setNote('Just some notes about John'); $employee->save(); $financeDepartment = $this->departmentFactory->create(); $financeDepartment->setName('Finance'); $financeDepartment->save(); $employee = $this->employeeFactory->create(); $employee->setDepartmentId($financeDepartment->getId()); $employee->setEmail('*****@*****.**'); $employee->setFirstName('Anna'); $employee->setLastName('Doe'); $employee->setServiceYears(5); $employee->setDob('1986-08-16'); $employee->setSalary(4200.0); $employee->setVatNumber('GB223344556'); $employee->setNote('Just some notes about Anna'); $employee->save(); $setup->endSetup(); }
/** * {@inheritdoc} */ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { $roleCollection = $this->authFactory->createRoleCollection()->addFieldToFilter('parent_id', 0)->addFieldToFilter('tree_level', 1)->addFieldToFilter('role_type', RoleGroup::ROLE_TYPE)->addFieldToFilter('user_id', 0)->addFieldToFilter('user_type', UserContextInterface::USER_TYPE_ADMIN)->addFieldToFilter('role_name', 'Administrators'); if ($roleCollection->count() == 0) { $admGroupRole = $this->authFactory->createRole()->setData(['parent_id' => 0, 'tree_level' => 1, 'sort_order' => 1, 'role_type' => RoleGroup::ROLE_TYPE, 'user_id' => 0, 'user_type' => UserContextInterface::USER_TYPE_ADMIN, 'role_name' => 'Administrators'])->save(); } else { foreach ($roleCollection as $item) { $admGroupRole = $item; break; } } $rulesCollection = $this->authFactory->createRulesCollection()->addFieldToFilter('role_id', $admGroupRole->getId())->addFieldToFilter('resource_id', 'all'); if ($rulesCollection->count() == 0) { $this->authFactory->createRules()->setData(['role_id' => $admGroupRole->getId(), 'resource_id' => 'Magento_Backend::all', 'privileges' => null, 'permission' => 'allow'])->save(); } else { /** @var \Magento\Authorization\Model\Rules $rule */ foreach ($rulesCollection as $rule) { $rule->setData('resource_id', 'Magento_Backend::all')->save(); } } /** * Delete rows by condition from authorization_rule */ $setup->startSetup(); $tableName = $setup->getTable('authorization_rule'); if ($tableName) { $setup->getConnection()->delete($tableName, ['resource_id = ?' => 'admin/system/tools/compiler']); } $setup->endSetup(); }
/** * {@inheritdoc} */ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { /** * Prepare database for install */ $setup->startSetup(); /** * PagSeguro Order Status */ $statuses = ['pagseguro_iniciado' => __('PagSeguro Iniciado'), 'pagseguro_aguardando_pagamento' => __('PagSeguro Aguardando Pagamento'), 'pagseguro_cancelada' => __('PagSeguro Cancelada'), 'pagseguro_chargeback_debitado' => __('PagSeguro Chargeback Debitado'), 'pagseguro_devolvida' => __('PagSeguro Devolvida'), 'pagseguro_disponivel' => __('PagSeguro Disponível'), 'pagseguro_em_analise' => __('PagSeguro Em Análise'), 'pagseguro_em_contestacao' => __('PagSeguro Em Contestação'), 'pagseguro_em_disputa' => __('PagSeguro Em Disputa'), 'pagseguro_paga' => __('PagSeguro Paga')]; foreach ($statuses as $code => $info) { $status[] = ['status' => $code, 'label' => $info]; $state[] = ['status' => $code, 'state' => 'new', 'is_default' => 0, 'visible_on_front' => '1']; } $setup->getConnection()->insertArray($setup->getTable('sales_order_status'), ['status', 'label'], $status); /** * PagSeguro Order State */ $state[0]['is_default'] = 1; $setup->getConnection()->insertArray($setup->getTable('sales_order_status_state'), ['status', 'state', 'is_default', 'visible_on_front'], $state); unset($data); /** * PagSeguro Store Reference */ $data[] = ['scope' => 'default', 'scope_id' => 0, 'path' => 'pagseguro/store/reference', 'value' => \UOL\PagSeguro\Helper\Data::generateStoreReference()]; $setup->getConnection()->insertArray($setup->getTable('core_config_data'), ['scope', 'scope_id', 'path', 'value'], $data); /** * Prepare database after install */ $setup->endSetup(); }
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { $setup->startSetup(); $helloText = $this->_helloTextFactory->create(); $helloText->setData('product', 14)->setText('Das ist nur ein Test')->save(); $setup->endSetup(); }
/** * {@inheritdoc} * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { $setup->startSetup(); if ($context->getVersion() && version_compare($context->getVersion(), '2.0.1') < 0) { $select = $setup->getConnection()->select()->from($setup->getTable('catalog_product_entity_group_price'), ['entity_id', 'all_groups', 'customer_group_id', new \Zend_Db_Expr('1'), 'value', 'website_id']); $select = $setup->getConnection()->insertFromSelect($select, $setup->getTable('catalog_product_entity_tier_price'), ['entity_id', 'all_groups', 'customer_group_id', 'qty', 'value', 'website_id']); $setup->getConnection()->query($select); $categorySetupManager = $this->categorySetupFactory->create(); $categorySetupManager->removeAttribute(\Magento\Catalog\Model\Product::ENTITY, 'group_price'); } if (version_compare($context->getVersion(), '2.0.2') < 0) { // set new resource model paths /** @var \Magento\Catalog\Setup\CategorySetup $categorySetup */ $categorySetup = $this->categorySetupFactory->create(['setup' => $setup]); $categorySetup->updateEntityType(\Magento\Catalog\Model\Category::ENTITY, 'entity_model', 'Magento\\Catalog\\Model\\ResourceModel\\Category'); $categorySetup->updateEntityType(\Magento\Catalog\Model\Category::ENTITY, 'attribute_model', 'Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute'); $categorySetup->updateEntityType(\Magento\Catalog\Model\Category::ENTITY, 'entity_attribute_collection', 'Magento\\Catalog\\Model\\ResourceModel\\Category\\Attribute\\Collection'); $categorySetup->updateAttribute(\Magento\Catalog\Model\Category::ENTITY, 'custom_design_from', 'attribute_model', 'Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute'); $categorySetup->updateEntityType(\Magento\Catalog\Model\Product::ENTITY, 'entity_model', 'Magento\\Catalog\\Model\\ResourceModel\\Product'); $categorySetup->updateEntityType(\Magento\Catalog\Model\Product::ENTITY, 'attribute_model', 'Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute'); $categorySetup->updateEntityType(\Magento\Catalog\Model\Product::ENTITY, 'entity_attribute_collection', 'Magento\\Catalog\\Model\\ResourceModel\\Product\\Attribute\\Collection'); } if (version_compare($context->getVersion(), '2.0.3') < 0) { /** @var \Magento\Catalog\Setup\CategorySetup $categorySetup */ $categorySetup = $this->categorySetupFactory->create(['setup' => $setup]); $categorySetup->updateAttribute(3, 51, 'default_value', 1); } if (version_compare($context->getVersion(), '2.0.4') < 0) { /** @var \Magento\Catalog\Setup\CategorySetup $categorySetup */ $categorySetup = $this->categorySetupFactory->create(['setup' => $setup]); $categorySetup->updateAttribute('catalog_product', 'media_gallery', 'backend_type', 'static'); $categorySetup->updateAttribute('catalog_product', 'media_gallery', 'backend_model'); } $setup->endSetup(); }
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { $setup->startSetup(); if (version_compare($context->getVersion(), '2.0.1', '<')) { /** * install vat exempt tax class */ $data = [['class_name' => 'Vatexempt Class', 'class_type' => \Magento\Tax\Model\ClassModel::TAX_CLASS_TYPE_PRODUCT]]; foreach ($data as $row) { $setup->getConnection()->insertForce($setup->getTable('tax_class'), $row); } /** * install vat exempt tax rate */ $data = [['tax_country_id' => 'US', 'tax_region_id' => '*', 'tax_postcode' => '*', 'code' => 'Vat Exempt', 'rate' => '0.00']]; foreach ($data as $row) { $setup->getConnection()->insertForce($setup->getTable('tax_calculation_rate'), $row); } /** * install vat exempt tax rule */ $this->_executor->exec($this->_installer); } $setup->endSetup(); }
/** * {@inheritdoc} * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { $setup->startSetup(); if (version_compare($context->getVersion(), '2.0.1') < 0) { /** @var \Magento\Catalog\Setup\CategorySetup $categorySetup */ $categorySetup = $this->categorySetupFactory->create(['setup' => $setup]); $entityTypeId = $categorySetup->getEntityTypeId(\Magento\Catalog\Model\Product::ENTITY); $attributeSetId = $categorySetup->getDefaultAttributeSetId($entityTypeId); $attributeGroup = $categorySetup->getAttributeGroup($entityTypeId, $attributeSetId, 'Images', 'attribute_group_name'); if (isset($attributeGroup['attribute_group_name']) && $attributeGroup['attribute_group_name'] == 'Images') { // update General Group $categorySetup->updateAttributeGroup($entityTypeId, $attributeSetId, $attributeGroup['attribute_group_id'], 'attribute_group_name', 'Images and Videos'); } } if ($context->getVersion() && version_compare($context->getVersion(), '2.0.1') < 0) { $select = $setup->getConnection()->select()->from($setup->getTable('catalog_product_entity_group_price'), ['entity_id', 'all_groups', 'customer_group_id', new \Zend_Db_Expr('1'), 'value', 'website_id']); $select = $setup->getConnection()->insertFromSelect($select, $setup->getTable('catalog_product_entity_tier_price'), ['entity_id', 'all_groups', 'customer_group_id', 'qty', 'value', 'website_id']); $setup->getConnection()->query($select); $categorySetupManager = $this->categorySetupFactory->create(); $categorySetupManager->removeAttribute(\Magento\Catalog\Model\Product::ENTITY, 'group_price'); } if (version_compare($context->getVersion(), '2.0.2') < 0) { // set new resource model paths /** @var \Magento\Catalog\Setup\CategorySetup $categorySetup */ $categorySetup = $this->categorySetupFactory->create(['setup' => $setup]); $categorySetup->updateEntityType(\Magento\Catalog\Model\Category::ENTITY, 'entity_model', 'Magento\\Catalog\\Model\\ResourceModel\\Category'); $categorySetup->updateEntityType(\Magento\Catalog\Model\Category::ENTITY, 'attribute_model', 'Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute'); $categorySetup->updateEntityType(\Magento\Catalog\Model\Category::ENTITY, 'entity_attribute_collection', 'Magento\\Catalog\\Model\\ResourceModel\\Category\\Attribute\\Collection'); $categorySetup->updateAttribute(\Magento\Catalog\Model\Category::ENTITY, 'custom_design_from', 'attribute_model', 'Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute'); $categorySetup->updateEntityType(\Magento\Catalog\Model\Product::ENTITY, 'entity_model', 'Magento\\Catalog\\Model\\ResourceModel\\Product'); $categorySetup->updateEntityType(\Magento\Catalog\Model\Product::ENTITY, 'attribute_model', 'Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute'); $categorySetup->updateEntityType(\Magento\Catalog\Model\Product::ENTITY, 'entity_attribute_collection', 'Magento\\Catalog\\Model\\ResourceModel\\Product\\Attribute\\Collection'); } $setup->endSetup(); }
/** * {@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(); }
/** * {@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(); }
/** * 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(); }
/** * @inheritdoc */ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { $this->_context = $context; $setup->startSetup(); /* perform module specific operations */ $this->_setup(); $setup->endSetup(); }
/** * {@inheritdoc} */ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { $installer = $setup->createMigrationSetup(); $setup->startSetup(); $installer->appendClassAliasReplace('core_config_data', 'value', Migration::ENTITY_TYPE_MODEL, Migration::FIELD_CONTENT_TYPE_PLAIN, ['config_id']); $installer->doUpdateClassAliases(); $setup->endSetup(); }
/** * {@inheritdoc} */ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { $installer = $setup->createMigrationSetup(); $setup->startSetup(); $installer->appendClassAliasReplace('widget_instance', 'instance_type', \Magento\Framework\Module\Setup\Migration::ENTITY_TYPE_BLOCK, \Magento\Framework\Module\Setup\Migration::FIELD_CONTENT_TYPE_PLAIN, ['instance_id']); $installer->appendClassAliasReplace('layout_update', 'xml', \Magento\Framework\Module\Setup\Migration::ENTITY_TYPE_BLOCK, \Magento\Framework\Module\Setup\Migration::FIELD_CONTENT_TYPE_XML, ['layout_update_id']); $installer->doUpdateClassAliases(); $setup->endSetup(); }
/** * {@inheritdoc} */ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { $installer = $setup->createMigrationSetup(); $setup->startSetup(); $installer->appendClassAliasReplace('salesrule', 'conditions_serialized', \Magento\Framework\Module\Setup\Migration::ENTITY_TYPE_MODEL, \Magento\Framework\Module\Setup\Migration::FIELD_CONTENT_TYPE_SERIALIZED, ['rule_id']); $installer->appendClassAliasReplace('salesrule', 'actions_serialized', \Magento\Framework\Module\Setup\Migration::ENTITY_TYPE_MODEL, \Magento\Framework\Module\Setup\Migration::FIELD_CONTENT_TYPE_SERIALIZED, ['rule_id']); $installer->doUpdateClassAliases(); $setup->endSetup(); }
/** * Sets used_in_recommender for relevant attributes * * @param ModuleDataSetupInterface $setup * @param ModuleContextInterface $context * @return void */ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { /** @var EavSetup $eavSetup */ $eavSetup = $this->_eavSetupFactory->create(['setup' => $setup]); $setup->startSetup(); foreach ($this->_helper->getSystemAttributesToUseInRecommender() as $code) { $eavSetup->updateAttribute(\Magento\Catalog\Model\Product::ENTITY, $code, 'used_in_recommender', true); } $setup->endSetup(); }
/** * {@inheritdoc} */ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { $setup->startSetup(); if (version_compare($context->getVersion(), '2.0.1', '<')) { $connection = $setup->getConnection(); $select = $connection->select()->from($this->relationProcessor->getTable('catalog_product_link'), ['product_id', 'linked_product_id'])->where('link_type_id = ?', Link::LINK_TYPE_GROUPED); $connection->query($connection->insertFromSelect($select, $this->relationProcessor->getMainTable(), ['parent_id', 'child_id'], AdapterInterface::INSERT_IGNORE)); } $setup->endSetup(); }
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { $installer = $setup; $setup->startSetup(); $connection = $installer->getConnection(); $select = $connection->select(); $select->from(['catalog_eav_attribute' => $installer->getTable('catalog_eav_attribute')], ['attribute_id', 'store_id' => new \Zend_Db_Expr(0)]); $connection->query($connection->insertFromSelect($select, $installer->getTable('genmato_multistoresearchfields_attribute_search_store'), ['attribute_id', 'store_id'])); $setup->endSetup(); }
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { $setup->startSetup(); if (version_compare($context->getVersion(), '2.0.1') < 0) { /** @var EavSetup $eavSetup */ $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]); $entityTypeId = $eavSetup->getEntityTypeId(Product::ENTITY); $eavSetup->addAttribute($entityTypeId, 'sample', ['type' => 'varchar', 'label' => 'Sample', 'input' => 'multiselect', 'global' => ScopedAttributeInterface::SCOPE_STORE, 'backend' => 'Magento\\Eav\\Model\\Entity\\Attribute\\Backend\\ArrayBackend', 'group' => 'Sample Group', 'visible_on_front' => 1, 'option' => ['values' => [0 => 'Sample Option One', 1 => 'Sample Option Two']]]); } $setup->endSetup(); }
/** * {@inheritdoc} */ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { $setup->startSetup(); if (version_compare($context->getVersion(), '2.0.1', '<')) { /** @var \Magento\Eav\Setup\EavSetup $eavSetup */ $eavSetup = $this->eavSetupFactory->create(); $groupId = (int) $eavSetup->getAttributeGroupByCode(Product::ENTITY, 'Default', 'image-management', 'attribute_group_id'); $eavSetup->addAttributeToGroup(Product::ENTITY, 'Default', $groupId, 'swatch_image'); } $setup->endSetup(); }
/** * {@inheritdoc} */ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { /** @var TaxSetup $taxSetup */ $taxSetup = $this->taxSetupFactory->create(['resourceName' => 'tax_setup', 'setup' => $setup]); $setup->startSetup(); if (version_compare($context->getVersion(), '2.0.1', '<')) { //Update the tax_class_id attribute in the 'catalog_eav_attribute' table $taxSetup->updateAttribute(\Magento\Catalog\Model\Product::ENTITY, 'tax_class_id', 'is_visible_in_advanced_search', false); } $setup->endSetup(); }
/** * {@inheritdoc} * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { $setup->startSetup(); $data = ['title' => 'title', 'link' => 'link', 'status' => 'status', 'image_link' => 'image_link', 'thumbnail_label' => 'thumbnail_label', 'rating' => 'rating', 'short_description' => 'short_description', 'mag_id' => 'mag_id', 'visible' => 'visible', 'store_id' => 'store_id', 'is_in_stock' => 'is_in_stock', 'sku' => 'sku', 'category' => 'category', 'websites' => 'websites', 'news_from_date' => 'news_from_date', 'news_to_date' => 'news_to_date']; $id = 1; foreach ($data as $xml_field => $code_field) { $setup->getConnection()->insertForce($setup->getTable('celebros_mapping'), ['id' => $id, 'xml_field' => $xml_field, 'code_field' => $code_field]); $id++; } $setup->endSetup(); }
/** * {@inheritdoc} */ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { $setup->startSetup(); $postSetup = $this->postSetupFactory->create(['setup' => $setup]); $postSetup->installEntities(); $categorySetup = $this->categorySetupFactory->create(['setup' => $setup]); $categorySetup->installEntities(); $setup->endSetup(); $this->eavConfig->clear(); $category = $categorySetup->getCategoryFactory()->create(); $category->setName(__('Blog'))->setParentId(null)->setPath('1')->setLevel(0)->setPosition(0)->setStatus(1)->save(); }
/** * Installs data for a module * * @param ModuleDataSetupInterface $setup * @param ModuleContextInterface $context * @return void */ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { $province = ['AG' => 'Agrigento', 'AL' => 'Alessandria', 'AN' => 'Ancona', 'AO' => 'Aosta', 'AR' => 'Arezzo', 'AP' => 'Ascoli Piceno', 'AT' => 'Asti', 'AV' => 'Avellino', 'BA' => 'Bari', 'BT' => 'Barletta-Andria-Trani', 'BL' => 'Belluno', 'BN' => 'Benevento', 'BG' => 'Bergamo', 'BI' => 'Biella', 'BO' => 'Bologna', 'BZ' => 'Bolzano', 'BS' => 'Brescia', 'BR' => 'Brindisi', 'CA' => 'Cagliari', 'CL' => 'Caltanissetta', 'CB' => 'Campobasso', 'CI' => 'Carbonia-Iglesias', 'CE' => 'Caserta', 'CT' => 'Catania', 'CZ' => 'Catanzaro', 'CH' => 'Chieti', 'CO' => 'Como', 'CS' => 'Cosenza', 'CR' => 'Cremona', 'KR' => 'Crotone', 'CN' => 'Cuneo', 'EN' => 'Enna', 'FM' => 'Fermo', 'FE' => 'Ferrara', 'FI' => 'Firenze', 'FG' => 'Foggia', 'FC' => 'Forlì-Cesena', 'FR' => 'Frosinone', 'GE' => 'Genova', 'GO' => 'Gorizia', 'GR' => 'Grosseto', 'IM' => 'Imperia', 'IS' => 'Isernia', 'SP' => 'La Spezia', 'AQ' => 'L\'Aquila', 'LT' => 'Latina', 'LE' => 'Lecce', 'LC' => 'Lecco', 'LI' => 'Livorno', 'LO' => 'Lodi', 'LU' => 'Lucca', 'MC' => 'Macerata', 'MN' => 'Mantova', 'MS' => 'Massa-Carrara', 'MT' => 'Matera', 'ME' => 'Messina', 'MI' => 'Milano', 'MO' => 'Modena', 'MB' => 'Monza e della Brianza', 'NA' => 'Napoli', 'NO' => 'Novara', 'NU' => 'Nuoro', 'OT' => 'Olbia-Tempio', 'OR' => 'Oristano', 'PD' => 'Padova', 'PA' => 'Palermo', 'PR' => 'Parma', 'PV' => 'Pavia', 'PG' => 'Perugia', 'PU' => 'Pesaro e Urbino', 'PE' => 'Pescara', 'PC' => 'Piacenza', 'PI' => 'Pisa', 'PT' => 'Pistoia', 'PN' => 'Pordenone', 'PZ' => 'Potenza', 'PO' => 'Prato', 'RG' => 'Ragusa', 'RA' => 'Ravenna', 'RC' => 'Reggio Calabria', 'RE' => 'Reggio Emilia', 'RI' => 'Rieti', 'RN' => 'Rimini', 'RM' => 'Roma', 'RO' => 'Rovigo', 'SA' => 'Salerno', 'VS' => 'Medio Campidano', 'SS' => 'Sassari', 'SV' => 'Savona', 'SI' => 'Siena', 'SR' => 'Siracusa', 'SO' => 'Sondrio', 'TA' => 'Taranto', 'TE' => 'Teramo', 'TR' => 'Terni', 'TO' => 'Torino', 'OG' => 'Ogliastra', 'TP' => 'Trapani', 'TN' => 'Trento', 'TV' => 'Treviso', 'TS' => 'Trieste', 'UD' => 'Udine', 'VA' => 'Varese', 'VE' => 'Venezia', 'VB' => 'Verbano-Cusio-Ossola', 'VC' => 'Vercelli', 'VR' => 'Verona', 'VV' => 'Vibo Valentia', 'VI' => 'Vicenza', 'VT' => 'Viterbo']; foreach ($province as $code => $name) { $bind = ['country_id' => 'IT', 'code' => $code, 'default_name' => $name]; $setup->getConnection()->insert($setup->getTable('directory_country_region'), $bind); $regionId = $setup->getConnection()->lastInsertId($setup->getTable('directory_country_region')); $bind = ['locale' => 'it_IT', 'region_id' => $regionId, 'name' => $name]; $setup->getConnection()->insert($setup->getTable('directory_country_region_name'), $bind); } $setup->endSetup(); }
/** * @SuppressWarnings(PHPMD.UnusedFormalParameter) * * Append virtual category related attributes : * - is_virtual_category * - virtual_rule * * @param ModuleDataSetupInterface $setup The setup interface * @param ModuleContextInterface $context The module Context * * @return void */ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { $setup->startSetup(); $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]); $eavSetup->addAttribute(Category::ENTITY, 'is_virtual_category', ['type' => 'int', 'label' => 'Is virtual category', 'input' => null, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL, 'required' => false, 'default' => 0, 'visible' => true, 'note' => "Is the category is virtual or not ?", 'sort_order' => 200, 'group' => 'General Information']); $eavSetup->addAttribute(Category::ENTITY, 'virtual_category_root', ['type' => 'int', 'label' => 'Virtual category root', 'input' => null, 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL, 'required' => false, 'default' => 0, 'visible' => true, 'note' => "Root display of the virtual category (usefull to display a facet category on virtual).", 'sort_order' => 200, 'group' => 'General Information']); $eavSetup->addAttribute(Category::ENTITY, 'virtual_rule', ['type' => 'text', 'label' => 'Virtual rule', 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL, 'backend' => 'Smile\\ElasticsuiteVirtualCategory\\Model\\Category\\Attribute\\Backend\\VirtualRule', 'required' => false, 'default' => null, 'visible' => true, 'note' => "Virtual category rule.", 'sort_order' => 210, 'group' => 'General Information']); // Force the frontend input to be null for these attributes since they are managed by code. $eavSetup->updateAttribute(Category::ENTITY, 'is_virtual_category', 'frontend_input', null); $eavSetup->updateAttribute(Category::ENTITY, 'virtual_category_root', 'frontend_input', null); $eavSetup->updateAttribute(Category::ENTITY, 'virtual_rule', 'frontend_input', null); $setup->endSetup(); }
/** * Upgrade the module data. * * @param ModuleDataSetupInterface $setup The setup interface * @param ModuleContextInterface $context The module Context * * @return void */ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { $setup->startSetup(); $this->eavSetup = $this->eavSetupFactory->create(['setup' => $setup]); if (version_compare($context->getVersion(), '1.2.0', '<')) { $this->updateCategorySearchableAttributes(); } if (version_compare($context->getVersion(), '1.2.1', '<')) { $productImageAttributeId = $this->eavSetup->getAttributeId(\Magento\Catalog\Model\Product::ENTITY, 'image'); $setup->getConnection()->update($setup->getTable('catalog_eav_attribute'), ['is_searchable' => 1], $setup->getConnection()->quoteInto('attribute_id = ?', $productImageAttributeId)); } $setup->endSetup(); }
/** * {@inheritdoc} * @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) */ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { /** @var CustomerSetup $customerSetup */ $customerSetup = $this->localizeSetupFactory->create(['setup' => $setup]); $setup->startSetup(); $attributes = ['firstnamekana' => ['type' => 'varchar', 'input' => 'text', 'visible' => true, 'required' => false, 'system' => 0, 'sort_order' => 45, 'validate_rules' => 'a:2:{s:15:"max_text_length";i:255;s:15:"min_text_length";i:1;}', 'position' => 45, 'label' => 'First name kana'], 'lastnamekana' => ['type' => 'varchar', 'input' => 'text', 'visible' => true, 'required' => false, 'system' => 0, 'sort_order' => 65, 'validate_rules' => 'a:2:{s:15:"max_text_length";i:255;s:15:"min_text_length";i:1;}', 'position' => 65, 'label' => 'Last name kana']]; foreach ($attributes as $code => $options) { $customerSetup->addAttribute(Customer::ENTITY, $code, $options); $customerSetup->addAttribute('customer_address', $code, $options); } $this->installCustomerForms($customerSetup, $attributes); $setup->endSetup(); }
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { $setup->startSetup(); $employeeEntity = \Foggyline\Office\Model\Employee::ENTITY; $employeeSetup = $this->employeeSetupFactory->create(['setup' => $setup]); $employeeSetup->installEntities(); $employeeSetup->addAttribute($employeeEntity, 'service_years', ['type' => 'int']); $employeeSetup->addAttribute($employeeEntity, 'dob', ['type' => 'datetime']); $employeeSetup->addAttribute($employeeEntity, 'salary', ['type' => 'decimal']); $employeeSetup->addAttribute($employeeEntity, 'vat_number', ['type' => 'varchar']); $employeeSetup->addAttribute($employeeEntity, 'note', ['type' => 'text']); $setup->endSetup(); }