本文整理匯總了PHP中Magento\Framework\Setup\ModuleContextInterface::getVersion方法的典型用法代碼示例。如果您正苦於以下問題:PHP ModuleContextInterface::getVersion方法的具體用法?PHP ModuleContextInterface::getVersion怎麽用?PHP ModuleContextInterface::getVersion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Framework\Setup\ModuleContextInterface
的用法示例。
在下文中一共展示了ModuleContextInterface::getVersion方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: upgrade
/**
* {@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();
}
示例2: upgrade
/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
{
$setup->startSetup();
if (version_compare($context->getVersion(), '2.0.0.1') < 0) {
$installer = $setup;
$connection = $installer->getConnection();
$tableNames = ['customer_address_entity_varchar', 'customer_address_entity_datetime', 'customer_address_entity_decimal', 'customer_address_entity_int', 'customer_address_entity_text', 'customer_entity_varchar', 'customer_entity_datetime', 'customer_entity_decimal', 'customer_entity_int', 'customer_entity_text'];
foreach ($tableNames as $table) {
$connection->dropForeignKey($installer->getTable($table), $installer->getFkName($table, 'entity_type_id', 'eav_entity_type', 'entity_type_id'));
$connection->dropIndex($installer->getTable($table), $installer->getIdxName($installer->getTable($table), ['entity_type_id'], \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_INDEX));
$connection->dropColumn($installer->getTable($table), 'entity_type_id');
}
$connection->dropColumn($installer->getTable('customer_address_entity'), 'entity_type_id');
$connection->dropColumn($installer->getTable('customer_address_entity'), 'attribute_set_id');
$connection->dropIndex($installer->getTable('customer_entity'), $installer->getIdxName('customer_entity', ['entity_type_id']));
$connection->dropColumn($installer->getTable('customer_entity'), 'entity_type_id');
$connection->dropColumn($installer->getTable('customer_entity'), 'attribute_set_id');
}
if (version_compare($context->getVersion(), '2.0.0.2') < 0) {
/**
* Update 'customer_visitor' table.
*/
$setup->getConnection()->addColumn($setup->getTable('customer_visitor'), 'customer_id', ['type' => Table::TYPE_INTEGER, 'after' => 'visitor_id', 'comment' => 'Customer ID']);
$setup->getConnection()->addIndex($setup->getTable('customer_visitor'), $setup->getIdxName($setup->getTable('customer_visitor'), ['customer_id']), 'customer_id');
/**
* Create 'customer_log' table.
*/
$table = $setup->getConnection()->newTable($setup->getTable('customer_log'))->addColumn('log_id', Table::TYPE_INTEGER, null, ['nullable' => false, 'identity' => true, 'primary' => true], 'Log ID')->addColumn('customer_id', Table::TYPE_INTEGER, null, ['nullable' => false], 'Customer ID')->addColumn('last_login_at', Table::TYPE_TIMESTAMP, null, ['nullable' => true, 'default' => null], 'Last Login Time')->addColumn('last_logout_at', Table::TYPE_TIMESTAMP, null, ['nullable' => true, 'default' => null], 'Last Logout Time')->addIndex($setup->getIdxName($setup->getTable('customer_log'), ['customer_id'], AdapterInterface::INDEX_TYPE_UNIQUE), ['customer_id'], ['type' => AdapterInterface::INDEX_TYPE_UNIQUE])->setComment('Customer Log Table');
$setup->getConnection()->createTable($table);
}
$setup->endSetup();
}
示例3: upgrade
/**
* {@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();
}
示例4: upgrade
/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
{
$installer = $setup;
$connection = $installer->getConnection();
if (version_compare($context->getVersion(), '2.0.1') < 0) {
$connection->dropIndex($setup->getTable('search_query'), $installer->getIdxName('search_query', ['query_text', 'store_id']));
$connection->addIndex($setup->getTable('search_query'), $installer->getIdxName('search_query', ['query_text', 'store_id'], \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE), ['query_text', 'store_id'], \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE);
}
if (version_compare($context->getVersion(), '2.0.2') < 0) {
/**
* Create table 'search_synonyms'
*/
$table = $connection->newTable($installer->getTable('search_synonyms'))->addColumn('group_id', \Magento\Framework\DB\Ddl\Table::TYPE_BIGINT, null, ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], 'Synonyms Group Id')->addColumn('synonyms', \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 65535, ['nullable' => false], 'list of synonyms making up this group')->addColumn('store_id', \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, null, ['unsigned' => true, 'nullable' => false, 'default' => '0'], 'Store Id - identifies the store view these synonyms belong to')->addIndex($setup->getIdxName($installer->getTable('search_synonyms'), ['synonyms'], AdapterInterface::INDEX_TYPE_FULLTEXT), ['synonyms'], ['type' => AdapterInterface::INDEX_TYPE_FULLTEXT])->addIndex($installer->getIdxName('search_synonyms', 'store_id'), ['store_id'], ['type' => AdapterInterface::INDEX_TYPE_INDEX])->addForeignKey($installer->getFkName('search_synonyms', 'store_id', 'store', 'store_id'), 'store_id', $installer->getTable('store'), 'store_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE)->setComment('table storing various synonyms groups per store view');
$connection->createTable($table);
}
if (version_compare($context->getVersion(), '2.0.3') < 0) {
// Drop and recreate 'search_synonyms' table
$connection->dropTable($installer->getTable('search_synonyms'));
$table = $connection->newTable($installer->getTable('search_synonyms'))->addColumn('group_id', \Magento\Framework\DB\Ddl\Table::TYPE_BIGINT, null, ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], 'Synonyms Group Id')->addColumn('synonyms', \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 65535, ['nullable' => false], 'list of synonyms making up this group')->addColumn('store_id', \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, null, ['unsigned' => true, 'nullable' => false, 'default' => '0'], 'Store Id - identifies the store view these synonyms belong to')->addColumn('website_id', \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, null, ['unsigned' => true, 'nullable' => false, 'default' => '0'], 'Website Id - identifies the website id these synonyms belong to')->addIndex($setup->getIdxName($installer->getTable('search_synonyms'), ['synonyms'], AdapterInterface::INDEX_TYPE_FULLTEXT), ['synonyms'], ['type' => AdapterInterface::INDEX_TYPE_FULLTEXT])->addIndex($installer->getIdxName('search_synonyms', 'store_id'), ['store_id'], ['type' => AdapterInterface::INDEX_TYPE_INDEX])->addIndex($installer->getIdxName('search_synonyms', 'website_id'), ['website_id'], ['type' => AdapterInterface::INDEX_TYPE_INDEX])->addForeignKey($installer->getFkName('search_synonyms', 'store_id', 'store', 'store_id'), 'store_id', $installer->getTable('store'), 'store_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE)->addForeignKey($installer->getFkName('search_synonyms', 'website_id', 'store_website', 'website_id'), 'website_id', $installer->getTable('store_website'), 'website_id', \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE)->setComment('table storing various synonyms groups');
$connection->createTable($table);
}
if (version_compare($context->getVersion(), '2.0.4') < 0) {
$connection->dropIndex($setup->getTable('search_query'), $installer->getIdxName('search_query', 'synonym_for'));
$connection->dropColumn($setup->getTable('search_query'), 'synonym_for');
}
}
示例5: upgrade
/**
* {@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();
}
示例6: upgrade
/**
* {@inheritdoc}
*/
public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
{
$setup->startSetup();
$connection = $setup->getConnection();
if (version_compare($context->getVersion(), '1.1.0', '<')) {
//remove quote table
$connection->dropTable($setup->getTable('email_quote'));
}
if (version_compare($context->getVersion(), '2.0.6', '<')) {
//modify email_campaign table
$campaignTable = $setup->getTable('email_campaign');
//add columns
$connection->addColumn($campaignTable, 'send_id', ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'nullable' => false, 'default' => '', 'comment' => 'Campaign Send Id']);
$connection->addColumn($campaignTable, 'send_status', ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, 'nullable' => false, 'default' => 0, 'comment' => 'Send Status']);
if ($connection->tableColumnExists($campaignTable, 'is_sent')) {
//update table with historical send values
$select = $connection->select();
//join
$select->joinLeft(['oc' => $campaignTable], "oc.id = nc.id", ['send_status' => new \Zend_Db_Expr(\Dotdigitalgroup\Email\Model\Campaign::SENT)])->where('oc.is_sent =?', 1);
//update query from select
$updateSql = $select->crossUpdateFromSelect(['nc' => $campaignTable]);
//run query
$connection->query($updateSql);
//remove column
$connection->dropColumn($campaignTable, 'is_sent');
}
//add index
$connection->addIndex($campaignTable, $setup->getIdxName($campaignTable, ['send_status']), ['send_status']);
}
if (version_compare($context->getVersion(), '2.1.0', '<')) {
$couponTable = $setup->getTable('salesrule_coupon');
$connection->addColumn($couponTable, 'generated_by_dotmailer', ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, 'nullable' => true, 'default' => null, 'comment' => '1 = Generated by dotmailer']);
}
$setup->endSetup();
}
示例7: upgrade
/**
* {@inheritdoc}
*/
public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
{
$setup->startSetup();
if (version_compare($context->getVersion(), '1.0.0.1', '<')) {
$this->updateSchemaVersion1001($setup);
}
if (version_compare($context->getVersion(), '1.0.0.2', '<')) {
$this->updateSchemaVersion1002($setup);
}
$setup->endSetup();
}
示例8: upgrade
/**
* {@inheritdoc}
*/
public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
{
$setup->startSetup();
if (version_compare($context->getVersion(), '2.0.1', '<')) {
$setup->getConnection()->addIndex($setup->getTable('quote_id_mask'), $setup->getIdxName('quote_id_mask', ['masked_id']), ['masked_id']);
}
if (version_compare($context->getVersion(), '2.0.2', '<')) {
$setup->getConnection()->changeColumn($setup->getTable('quote_address'), 'street', 'street', ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'length' => 255, 'comment' => 'Street']);
}
$setup->endSetup();
}
示例9: upgrade
/**
* {@inheritdoc}
*/
public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
{
$setup->startSetup();
if (version_compare($context->getVersion(), '2.0.1', '<')) {
$this->addSupportVideoMediaAttributes($setup);
$this->removeGroupPrice($setup);
}
if (version_compare($context->getVersion(), '2.0.6', '<')) {
$this->addUniqueKeyToCategoryProductTable($setup);
}
$setup->endSetup();
}
示例10: upgrade
/**
* 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();
}
示例11: upgrade
/**
* Installs DB schema for a module
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @param SchemaSetupInterface $setup Setup
* @param ModuleContextInterface $context Context
*
* @return void
*/
public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
{
$setup->startSetup();
if (version_compare($context->getVersion(), '0.0.2', '<')) {
$this->createThesaurusTable($setup);
$this->createThesaurusStoreTable($setup);
$this->createExpandedTermsTable($setup);
$this->createExpansionReferenceTable($setup);
}
if (version_compare($context->getVersion(), '1.0.0', '<')) {
$this->appendIsActiveColumn($setup);
}
$setup->endSetup();
}
示例12: upgrade
/**
* {@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();
}
示例13: upgrade
public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
{
$setup->startSetup();
//No previous version found, installation, InstallSchema was just executed
if (!$context->getVersion()) {
}
//code to upgrade to 2.0.1
if (version_compare($context->getVersion(), '2.0.1') < 0) {
$this->createPagSeguroOrdersTable($setup);
$this->integratePagSeguroAndOrdersGrid($setup);
$this->cleanUiBookmark($setup);
}
$setup->endSetup();
}
示例14: upgrade
/**
* {@inheritdoc}
*/
public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
{
$setup->startSetup();
if (version_compare($context->getVersion(), '2.0.0.1') < 0) {
$connection = $setup->getConnection();
$connection->addIndex($setup->getTable('customer_visitor'), $setup->getIdxName('customer_visitor', ['last_visit_at']), ['last_visit_at']);
}
if (version_compare($context->getVersion(), '2.0.1', '<')) {
$setup->getConnection()->addColumn($setup->getTable('customer_eav_attribute'), 'is_used_in_grid', ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, 'unsigned' => true, 'nullable' => false, 'default' => '0', 'comment' => 'Is Used in Grid']);
$setup->getConnection()->addColumn($setup->getTable('customer_eav_attribute'), 'is_visible_in_grid', ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, 'unsigned' => true, 'nullable' => false, 'default' => '0', 'comment' => 'Is Visible in Grid']);
$setup->getConnection()->addColumn($setup->getTable('customer_eav_attribute'), 'is_filterable_in_grid', ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, 'unsigned' => true, 'nullable' => false, 'default' => '0', 'comment' => 'Is Filterable in Grid']);
$setup->getConnection()->addColumn($setup->getTable('customer_eav_attribute'), 'is_searchable_in_grid', ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, 'unsigned' => true, 'nullable' => false, 'default' => '0', 'comment' => 'Is Searchable in Grid']);
}
$setup->endSetup();
}
示例15: upgrade
/**
* Upgrades DB schema for a module
*
* @param SchemaSetupInterface $setup
* @param ModuleContextInterface $context
* @return void
*/
public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
{
$setup->startSetup();
if (version_compare($context->getVersion(), '1.0.1', '<')) {
$setup->getConnection()->addColumn($setup->getTable('fastgento_locator'), 'image', ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'nullable' => true, 'comment' => 'Location image attribute']);
}
if (version_compare($context->getVersion(), '1.0.2', '<')) {
/**
* Drop entity Id columns
*/
$setup->getConnection()->dropColumn($setup->getTable('fastgento_locator'), 'image');
$setup->getConnection()->addColumn($setup->getTable('fastgento_locator'), 'image', ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'nullable' => true, 'comment' => 'Location image attribute']);
}
$setup->endSetup();
}