How to keep module enabled across instances in Magento 2? Announcing the arrival of Valued...
Could a cockatrice have parasitic embryos?
Is there a possibility to generate a list dynamically in Latex?
Why I cannot instantiate a class whose constructor is private in a friend class?
Determinant of a matrix with 2 equal rows
How did Elite on the NES work?
Marquee sign letters
What is a 'Key' in computer science?
What happened to Viserion in Season 7?
Mechanism of the formation of peracetic acid
What is the purpose of the side handle on a hand ("eggbeater") drill?
Why does the Cisco show run command not show the full version, while the show version command does?
Is there a verb for listening stealthily?
In search of the origins of term censor, I hit a dead end stuck with the greek term, to censor, λογοκρίνω
How would it unbalance gameplay to rule that Weapon Master allows for picking a fighting style?
Why isn't everyone flabbergasted about Bran's "gift"?
Like totally amazing interchangeable sister outfit accessory swapping or whatever
1 column , 2 columns-left , 2 columns-right , 3 column
Suing a Police Officer Instead of the Police Department
When I export an AI 300x60 art board it saves with bigger dimensions
Coin Game with infinite paradox
What helicopter has the most rotor blades?
Is it appropriate to mention a relatable company blog post when you're asked about the company?
Does Prince Arnaud cause someone holding the Princess to lose?
Philosophers who were composers?
How to keep module enabled across instances in Magento 2?
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?How to change theme for magento multiple store?Configuration MigrationMagento 2: How to Read From Configuration TreeMagento 2 - Environment dependent configurationConditional RequireJs configuration (Load requirejs-config.js programmatically?)How can I find all config entries for enabled payment or shipping methods and copy them to another store?How to print all magento configurations (config array) : Magento 2Magento 2 CAPTCHA not showing when enabledHow to Migrate two different Magento 1 instances to Magento 2?Magento 2: how to hide product from minicart
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
is there any way to keep free contributed plugin (for example MageMonkey 2) to be enabled across different instances of website(dev, stage, prod), keeping the configuration?
magento2 module configuration
add a comment |
is there any way to keep free contributed plugin (for example MageMonkey 2) to be enabled across different instances of website(dev, stage, prod), keeping the configuration?
magento2 module configuration
As per I know currently we don't have mixture of this 2 commandsphp bin/magento deploy:mode:set developer/production
&php bin/magento module:enable MODULE_NAME
– Ankit Shah
Mar 29 '17 at 8:53
Thank You, for response. I can execute this commands in my CI scripts, I meant more generic way, for example to enable module in update script from other module, or extension allowing to keep configuration through instances, like features in drupal, or some hook around composer.
– Damir Gadiev
Mar 29 '17 at 9:16
add a comment |
is there any way to keep free contributed plugin (for example MageMonkey 2) to be enabled across different instances of website(dev, stage, prod), keeping the configuration?
magento2 module configuration
is there any way to keep free contributed plugin (for example MageMonkey 2) to be enabled across different instances of website(dev, stage, prod), keeping the configuration?
magento2 module configuration
magento2 module configuration
edited 28 mins ago
Muhammad Anas
8091322
8091322
asked Mar 29 '17 at 8:35
Damir GadievDamir Gadiev
62
62
As per I know currently we don't have mixture of this 2 commandsphp bin/magento deploy:mode:set developer/production
&php bin/magento module:enable MODULE_NAME
– Ankit Shah
Mar 29 '17 at 8:53
Thank You, for response. I can execute this commands in my CI scripts, I meant more generic way, for example to enable module in update script from other module, or extension allowing to keep configuration through instances, like features in drupal, or some hook around composer.
– Damir Gadiev
Mar 29 '17 at 9:16
add a comment |
As per I know currently we don't have mixture of this 2 commandsphp bin/magento deploy:mode:set developer/production
&php bin/magento module:enable MODULE_NAME
– Ankit Shah
Mar 29 '17 at 8:53
Thank You, for response. I can execute this commands in my CI scripts, I meant more generic way, for example to enable module in update script from other module, or extension allowing to keep configuration through instances, like features in drupal, or some hook around composer.
– Damir Gadiev
Mar 29 '17 at 9:16
As per I know currently we don't have mixture of this 2 commands
php bin/magento deploy:mode:set developer/production
& php bin/magento module:enable MODULE_NAME
– Ankit Shah
Mar 29 '17 at 8:53
As per I know currently we don't have mixture of this 2 commands
php bin/magento deploy:mode:set developer/production
& php bin/magento module:enable MODULE_NAME
– Ankit Shah
Mar 29 '17 at 8:53
Thank You, for response. I can execute this commands in my CI scripts, I meant more generic way, for example to enable module in update script from other module, or extension allowing to keep configuration through instances, like features in drupal, or some hook around composer.
– Damir Gadiev
Mar 29 '17 at 9:16
Thank You, for response. I can execute this commands in my CI scripts, I meant more generic way, for example to enable module in update script from other module, or extension allowing to keep configuration through instances, like features in drupal, or some hook around composer.
– Damir Gadiev
Mar 29 '17 at 9:16
add a comment |
1 Answer
1
active
oldest
votes
Suggested solution:
I've managed situation by adding required module to composer.json of my custom administrative module managing dependencies to another modules and adding UpgradeData.php with update script.
More detailed explanation:
Code structure
|--app/
|--code/
|--<My Vendor>/
|-- ...
|--<My Module>/
|-- ...
|--Helper
|--Configuration.php
|--Setup/
|--UpgradeData.php # save custom module settings here
|-- ...
|--composer.json # module's composer file
|-- ...
|--vendor/
|--<ContribVendor>/
|--<ContribModule>/
|-- ...
|--composer.json # home directory composer file
|--auth.json # can be gitignored
Module composer.json sample
{
"name": "<My Vendor>/<My Module>",
"description": "N/A",
"require": {
"php": "~5.6.5|7.0.2|7.0.4|~7.0.6",
"<Custom Vendor>/<Custom Module>": "<Module Version>"
},
"type": "magento2-module",
"version": "<My Module version>",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"autoload": {
"files": [
"registration.php"
]
}
}
Upgrade script sample:
<?php
namespace <MyVendor>UpdatesSetup;
use MagentoFrameworkSetupUpgradeDataInterface;
use MagentoFrameworkSetupModuleContextInterface;
use MagentoFrameworkSetupModuleDataSetupInterface;
use <MyVendor><My Module>HelperConfiguration;
class UpgradeData implements UpgradeDataInterface
{
/**
* @var <MyVendor><My Module>HelperConfiguration
*/
protected $config;
public function __construct(
Configuration $config
) {
$this->config = $config;
}
/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$setup->startSetup();
try {
if (version_compare($context->getVersion(), '<ModuleVersion>', '<=')) {
$this->config->setMyModuleSettings(); # Implemented in HELPER below.
}
}
catch (Exception $e) {
print $e->getMessage();
}
$setup->endSetup();
}
}
Helper script sample:
<?php
namespace FFWUpdatesHelper;
use MagentoConfigModelResourceModelConfig;
use MagentoFrameworkAppHelperContext;
class Configuration extends MagentoFrameworkAppHelperAbstractHelper {
/**
* @var MagentoConfigModelResourceModelConfig
*/
protected $config;
public function construct(
Context $context,
Config $config
) {
parent::__construct($context);
$this->config = $config;
}
/**
* Helper to set <My Module> settings.
*/
public function setMyModuleSettings() {
$this->config->saveConfig('<Config key according to schema.xml of module implementing config - ContribModule in our case>', <Value>, '<Scope>', '<ScopeId>');
}
}
Final step
I my CI i run 2 steps on each deployment - during development:
magento setup:upgrade
magento setup:di:compile
Disclaimer
Do not forget to add your api keys for contrib module to composer auth.json file (or any other authentication method for composer).
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f166688%2fhow-to-keep-module-enabled-across-instances-in-magento-2%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Suggested solution:
I've managed situation by adding required module to composer.json of my custom administrative module managing dependencies to another modules and adding UpgradeData.php with update script.
More detailed explanation:
Code structure
|--app/
|--code/
|--<My Vendor>/
|-- ...
|--<My Module>/
|-- ...
|--Helper
|--Configuration.php
|--Setup/
|--UpgradeData.php # save custom module settings here
|-- ...
|--composer.json # module's composer file
|-- ...
|--vendor/
|--<ContribVendor>/
|--<ContribModule>/
|-- ...
|--composer.json # home directory composer file
|--auth.json # can be gitignored
Module composer.json sample
{
"name": "<My Vendor>/<My Module>",
"description": "N/A",
"require": {
"php": "~5.6.5|7.0.2|7.0.4|~7.0.6",
"<Custom Vendor>/<Custom Module>": "<Module Version>"
},
"type": "magento2-module",
"version": "<My Module version>",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"autoload": {
"files": [
"registration.php"
]
}
}
Upgrade script sample:
<?php
namespace <MyVendor>UpdatesSetup;
use MagentoFrameworkSetupUpgradeDataInterface;
use MagentoFrameworkSetupModuleContextInterface;
use MagentoFrameworkSetupModuleDataSetupInterface;
use <MyVendor><My Module>HelperConfiguration;
class UpgradeData implements UpgradeDataInterface
{
/**
* @var <MyVendor><My Module>HelperConfiguration
*/
protected $config;
public function __construct(
Configuration $config
) {
$this->config = $config;
}
/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$setup->startSetup();
try {
if (version_compare($context->getVersion(), '<ModuleVersion>', '<=')) {
$this->config->setMyModuleSettings(); # Implemented in HELPER below.
}
}
catch (Exception $e) {
print $e->getMessage();
}
$setup->endSetup();
}
}
Helper script sample:
<?php
namespace FFWUpdatesHelper;
use MagentoConfigModelResourceModelConfig;
use MagentoFrameworkAppHelperContext;
class Configuration extends MagentoFrameworkAppHelperAbstractHelper {
/**
* @var MagentoConfigModelResourceModelConfig
*/
protected $config;
public function construct(
Context $context,
Config $config
) {
parent::__construct($context);
$this->config = $config;
}
/**
* Helper to set <My Module> settings.
*/
public function setMyModuleSettings() {
$this->config->saveConfig('<Config key according to schema.xml of module implementing config - ContribModule in our case>', <Value>, '<Scope>', '<ScopeId>');
}
}
Final step
I my CI i run 2 steps on each deployment - during development:
magento setup:upgrade
magento setup:di:compile
Disclaimer
Do not forget to add your api keys for contrib module to composer auth.json file (or any other authentication method for composer).
add a comment |
Suggested solution:
I've managed situation by adding required module to composer.json of my custom administrative module managing dependencies to another modules and adding UpgradeData.php with update script.
More detailed explanation:
Code structure
|--app/
|--code/
|--<My Vendor>/
|-- ...
|--<My Module>/
|-- ...
|--Helper
|--Configuration.php
|--Setup/
|--UpgradeData.php # save custom module settings here
|-- ...
|--composer.json # module's composer file
|-- ...
|--vendor/
|--<ContribVendor>/
|--<ContribModule>/
|-- ...
|--composer.json # home directory composer file
|--auth.json # can be gitignored
Module composer.json sample
{
"name": "<My Vendor>/<My Module>",
"description": "N/A",
"require": {
"php": "~5.6.5|7.0.2|7.0.4|~7.0.6",
"<Custom Vendor>/<Custom Module>": "<Module Version>"
},
"type": "magento2-module",
"version": "<My Module version>",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"autoload": {
"files": [
"registration.php"
]
}
}
Upgrade script sample:
<?php
namespace <MyVendor>UpdatesSetup;
use MagentoFrameworkSetupUpgradeDataInterface;
use MagentoFrameworkSetupModuleContextInterface;
use MagentoFrameworkSetupModuleDataSetupInterface;
use <MyVendor><My Module>HelperConfiguration;
class UpgradeData implements UpgradeDataInterface
{
/**
* @var <MyVendor><My Module>HelperConfiguration
*/
protected $config;
public function __construct(
Configuration $config
) {
$this->config = $config;
}
/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$setup->startSetup();
try {
if (version_compare($context->getVersion(), '<ModuleVersion>', '<=')) {
$this->config->setMyModuleSettings(); # Implemented in HELPER below.
}
}
catch (Exception $e) {
print $e->getMessage();
}
$setup->endSetup();
}
}
Helper script sample:
<?php
namespace FFWUpdatesHelper;
use MagentoConfigModelResourceModelConfig;
use MagentoFrameworkAppHelperContext;
class Configuration extends MagentoFrameworkAppHelperAbstractHelper {
/**
* @var MagentoConfigModelResourceModelConfig
*/
protected $config;
public function construct(
Context $context,
Config $config
) {
parent::__construct($context);
$this->config = $config;
}
/**
* Helper to set <My Module> settings.
*/
public function setMyModuleSettings() {
$this->config->saveConfig('<Config key according to schema.xml of module implementing config - ContribModule in our case>', <Value>, '<Scope>', '<ScopeId>');
}
}
Final step
I my CI i run 2 steps on each deployment - during development:
magento setup:upgrade
magento setup:di:compile
Disclaimer
Do not forget to add your api keys for contrib module to composer auth.json file (or any other authentication method for composer).
add a comment |
Suggested solution:
I've managed situation by adding required module to composer.json of my custom administrative module managing dependencies to another modules and adding UpgradeData.php with update script.
More detailed explanation:
Code structure
|--app/
|--code/
|--<My Vendor>/
|-- ...
|--<My Module>/
|-- ...
|--Helper
|--Configuration.php
|--Setup/
|--UpgradeData.php # save custom module settings here
|-- ...
|--composer.json # module's composer file
|-- ...
|--vendor/
|--<ContribVendor>/
|--<ContribModule>/
|-- ...
|--composer.json # home directory composer file
|--auth.json # can be gitignored
Module composer.json sample
{
"name": "<My Vendor>/<My Module>",
"description": "N/A",
"require": {
"php": "~5.6.5|7.0.2|7.0.4|~7.0.6",
"<Custom Vendor>/<Custom Module>": "<Module Version>"
},
"type": "magento2-module",
"version": "<My Module version>",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"autoload": {
"files": [
"registration.php"
]
}
}
Upgrade script sample:
<?php
namespace <MyVendor>UpdatesSetup;
use MagentoFrameworkSetupUpgradeDataInterface;
use MagentoFrameworkSetupModuleContextInterface;
use MagentoFrameworkSetupModuleDataSetupInterface;
use <MyVendor><My Module>HelperConfiguration;
class UpgradeData implements UpgradeDataInterface
{
/**
* @var <MyVendor><My Module>HelperConfiguration
*/
protected $config;
public function __construct(
Configuration $config
) {
$this->config = $config;
}
/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$setup->startSetup();
try {
if (version_compare($context->getVersion(), '<ModuleVersion>', '<=')) {
$this->config->setMyModuleSettings(); # Implemented in HELPER below.
}
}
catch (Exception $e) {
print $e->getMessage();
}
$setup->endSetup();
}
}
Helper script sample:
<?php
namespace FFWUpdatesHelper;
use MagentoConfigModelResourceModelConfig;
use MagentoFrameworkAppHelperContext;
class Configuration extends MagentoFrameworkAppHelperAbstractHelper {
/**
* @var MagentoConfigModelResourceModelConfig
*/
protected $config;
public function construct(
Context $context,
Config $config
) {
parent::__construct($context);
$this->config = $config;
}
/**
* Helper to set <My Module> settings.
*/
public function setMyModuleSettings() {
$this->config->saveConfig('<Config key according to schema.xml of module implementing config - ContribModule in our case>', <Value>, '<Scope>', '<ScopeId>');
}
}
Final step
I my CI i run 2 steps on each deployment - during development:
magento setup:upgrade
magento setup:di:compile
Disclaimer
Do not forget to add your api keys for contrib module to composer auth.json file (or any other authentication method for composer).
Suggested solution:
I've managed situation by adding required module to composer.json of my custom administrative module managing dependencies to another modules and adding UpgradeData.php with update script.
More detailed explanation:
Code structure
|--app/
|--code/
|--<My Vendor>/
|-- ...
|--<My Module>/
|-- ...
|--Helper
|--Configuration.php
|--Setup/
|--UpgradeData.php # save custom module settings here
|-- ...
|--composer.json # module's composer file
|-- ...
|--vendor/
|--<ContribVendor>/
|--<ContribModule>/
|-- ...
|--composer.json # home directory composer file
|--auth.json # can be gitignored
Module composer.json sample
{
"name": "<My Vendor>/<My Module>",
"description": "N/A",
"require": {
"php": "~5.6.5|7.0.2|7.0.4|~7.0.6",
"<Custom Vendor>/<Custom Module>": "<Module Version>"
},
"type": "magento2-module",
"version": "<My Module version>",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"autoload": {
"files": [
"registration.php"
]
}
}
Upgrade script sample:
<?php
namespace <MyVendor>UpdatesSetup;
use MagentoFrameworkSetupUpgradeDataInterface;
use MagentoFrameworkSetupModuleContextInterface;
use MagentoFrameworkSetupModuleDataSetupInterface;
use <MyVendor><My Module>HelperConfiguration;
class UpgradeData implements UpgradeDataInterface
{
/**
* @var <MyVendor><My Module>HelperConfiguration
*/
protected $config;
public function __construct(
Configuration $config
) {
$this->config = $config;
}
/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$setup->startSetup();
try {
if (version_compare($context->getVersion(), '<ModuleVersion>', '<=')) {
$this->config->setMyModuleSettings(); # Implemented in HELPER below.
}
}
catch (Exception $e) {
print $e->getMessage();
}
$setup->endSetup();
}
}
Helper script sample:
<?php
namespace FFWUpdatesHelper;
use MagentoConfigModelResourceModelConfig;
use MagentoFrameworkAppHelperContext;
class Configuration extends MagentoFrameworkAppHelperAbstractHelper {
/**
* @var MagentoConfigModelResourceModelConfig
*/
protected $config;
public function construct(
Context $context,
Config $config
) {
parent::__construct($context);
$this->config = $config;
}
/**
* Helper to set <My Module> settings.
*/
public function setMyModuleSettings() {
$this->config->saveConfig('<Config key according to schema.xml of module implementing config - ContribModule in our case>', <Value>, '<Scope>', '<ScopeId>');
}
}
Final step
I my CI i run 2 steps on each deployment - during development:
magento setup:upgrade
magento setup:di:compile
Disclaimer
Do not forget to add your api keys for contrib module to composer auth.json file (or any other authentication method for composer).
answered Mar 31 '17 at 7:42
Damir GadievDamir Gadiev
62
62
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f166688%2fhow-to-keep-module-enabled-across-instances-in-magento-2%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
As per I know currently we don't have mixture of this 2 commands
php bin/magento deploy:mode:set developer/production
&php bin/magento module:enable MODULE_NAME
– Ankit Shah
Mar 29 '17 at 8:53
Thank You, for response. I can execute this commands in my CI scripts, I meant more generic way, for example to enable module in update script from other module, or extension allowing to keep configuration through instances, like features in drupal, or some hook around composer.
– Damir Gadiev
Mar 29 '17 at 9:16