作者:BlackIkeEagl
项目:magento2-continuousph
/**
* {@inheritdoc}
*/
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$setup->startSetup();
$indexer = $this->indexerRegistry->get(Config::DESIGN_CONFIG_GRID_INDEXER_ID);
$indexer->reindexAll();
$setup->endSetup();
}
作者:Galille
项目:B05032-Foggyline_Offic
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('john@sales.loc');
$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('anna@sales.loc');
$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();
}
作者:shabbirvividad
项目:magento
/**
* {@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();
}
作者:TUDOC
项目:tudockblog-magento2-exampl
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();
}
作者:pradeep-wagent
项目:magento
/**
* {@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();
}
作者:tozwier
项目:magento2_payup
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$connection = $setup->getConnection();
// add Pending Payu.pl status to Pending Payment state
$connection->insert($setup->getTable('sales_order_status'), ['status' => 'pending_payupl', 'label' => 'Pending Payu.pl']);
$connection->insert($setup->getTable('sales_order_status_state'), ['status' => 'pending_payupl', 'state' => 'pending_payment', 'is_default' => 0, 'visible_on_front' => 1]);
}
作者:kidaa3
项目:magento2-platforms
/**
* {@inheritdoc}
*/
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
/*
* Register themes
*/
$setup->getEventManager()->dispatch('theme_registration_from_filesystem');
/**
* Update theme's data
*/
$fileCollection = $this->createTheme();
$fileCollection->setItemObjectClass('Magento\\Theme\\Model\\Theme\\Data');
$resourceCollection = $this->createThemeResource();
$resourceCollection->setItemObjectClass('Magento\\Theme\\Model\\Theme\\Data');
/** @var $theme \Magento\Framework\View\Design\ThemeInterface */
foreach ($resourceCollection as $theme) {
$themeType = $fileCollection->hasTheme($theme) ? \Magento\Framework\View\Design\ThemeInterface::TYPE_PHYSICAL : \Magento\Framework\View\Design\ThemeInterface::TYPE_VIRTUAL;
$theme->setType($themeType)->save();
}
$fileCollection = $this->createTheme();
$fileCollection->setItemObjectClass('Magento\\Theme\\Model\\Theme\\Data');
$themeDbCollection = $this->createThemeResource();
$themeDbCollection->setItemObjectClass('Magento\\Theme\\Model\\Theme\\Data');
/** @var $theme \Magento\Framework\View\Design\ThemeInterface */
foreach ($fileCollection as $theme) {
$dbTheme = $themeDbCollection->getThemeByFullPath($theme->getFullPath());
$dbTheme->setCode($theme->getCode());
$dbTheme->save();
}
/**
* Update rows in theme
*/
$setup->getConnection()->update($setup->getTable('theme'), ['area' => 'frontend'], ['area = ?' => '']);
}
作者:kidaa3
项目:magento2-platforms
/**
* {@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();
}
作者:antonkri
项目:m2experienc
/**
* 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();
}
作者:praxigent
项目:mobi_mod_mage2_cor
/**
* @inheritdoc
*/
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$this->_context = $context;
$setup->startSetup();
/* perform module specific operations */
$this->_setup();
$setup->endSetup();
}
作者:kidaa3
项目:magento2-platforms
/**
* {@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();
}
作者:kidaa3
项目:magento2-platforms
/**
* {@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();
}
作者:kidaa3
项目:magento2-platforms
/**
* {@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();
}
作者:smile-s
项目:elasticsuit
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* Installs Data for the module :
* - Create attribute on category to enable/disable name indexation for search
* - Update is anchor attribute (hidden frontend input, null source model, enabled by default).
*
* @param ModuleDataSetupInterface $setup The setup interface
* @param ModuleContextInterface $context The module Context
*
* @return void
*/
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$setup->startSetup();
$this->eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
$this->addCategoryNameSearchAttribute();
$this->updateCategoryIsAnchorAttribute();
$this->updateDefaultValuesForNameAttributes();
$this->getIndexer('elasticsuite_categories_fulltext')->reindexAll();
$setup->endSetup();
}
作者:Genmat
项目:M2_MultistoreSearchField
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();
}
作者:Doabilit
项目:magento2de
/**
* {@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();
}
作者:hal
项目:recowise-magento2-dem
/**
* 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();
}
作者:pagsegur
项目:magento
/**
* {@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();
}
作者:rafaelst
项目:magento
/**
* {@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();
}
作者:andrew-smar
项目:magento2-sample-modul
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();
}