how to active/deactive a module for each store by admin in magento 2.2Enable 'Use in Advanced Search' option of product attribute for only one multi-siteHow to disable Magento 2 reviewsStore level User Permission In Magento BackendMagento 2: How to disable Minify CSS JS setting?Magento 2 - Create Admin Grid and show Custom Module list with Enable/Disable optionMagento 2 admin is not working after disable Magento_ThemeMagento 2.2 Open Source restrictions on each settingHow to disable magento 2 extension in store view (multistore)Have a option to enable/disable the module. I need to load admin page css when my module is enabled. No need to load css while module is disableHow to setup different Advanced Inventory Options for each store?

When India mathematicians did know Euclid's Elements?

How to determine the actual or "true" resolution of a digital photograph?

How can I record the screen and the rear camera on an iPhone simultaneously?

How to back up a running remote server?

Is it possible to measure lightning discharges as Nikola Tesla?

Multiple options for Pseudonyms

What does YCWCYODFTRFDTY mean?

Reverse the word in a string with the same order in javascript

Please, smoke with good manners

Is thermodynamics only applicable to systems in equilibrium?

What are the spoon bit of a spoon and fork bit of a fork called?

What's the polite way to say "I need to urinate"?

Can someone publish a story that happened to you?

Pulling the rope with one hand is as heavy as with two hands?

Can fracking help reduce CO2?

Is creating your own "experiment" considered cheating during a physics exam?

Why do computer-science majors learn calculus?

Stark VS Thanos

Has any spacecraft ever had the ability to directly communicate with civilian air traffic control?

Why does Bran Stark feel that Jon Snow "needs to know" about his lineage?

Sci-fi novel series with instant travel between planets through gates. A river runs through the gates

What is a Recurrent Neural Network?

Why does processed meat contain preservatives, while canned fish needs not?

Why are the 2nd/3rd singular forms of present of « potere » irregular?



how to active/deactive a module for each store by admin in magento 2.2


Enable 'Use in Advanced Search' option of product attribute for only one multi-siteHow to disable Magento 2 reviewsStore level User Permission In Magento BackendMagento 2: How to disable Minify CSS JS setting?Magento 2 - Create Admin Grid and show Custom Module list with Enable/Disable optionMagento 2 admin is not working after disable Magento_ThemeMagento 2.2 Open Source restrictions on each settingHow to disable magento 2 extension in store view (multistore)Have a option to enable/disable the module. I need to load admin page css when my module is enabled. No need to load css while module is disableHow to setup different Advanced Inventory Options for each store?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I want to give ability to admin to active or deactive a module for each store.



at previous magento version this option was exist under store -> configuration -> advanced -> advanced menue and we could enable or disable a module per store , but from magento 2.2 this option has been removed and no longer avalable.



according this link for this purpose we have to do some setting manually in our module .



I want to make setting in my module that admin can see the list of stores and by selecting them to enable or disable a module . for example admin wants to enable module be active for store A and B , and deactive for store C .



the list of stores should be dynamic and reads from database and shouldn't be hard code.



I don't have any idea how can I do it .Someone can help me figure out how I can do it ? If you could please point this out, I would be really grateful .










share|improve this question






























    0















    I want to give ability to admin to active or deactive a module for each store.



    at previous magento version this option was exist under store -> configuration -> advanced -> advanced menue and we could enable or disable a module per store , but from magento 2.2 this option has been removed and no longer avalable.



    according this link for this purpose we have to do some setting manually in our module .



    I want to make setting in my module that admin can see the list of stores and by selecting them to enable or disable a module . for example admin wants to enable module be active for store A and B , and deactive for store C .



    the list of stores should be dynamic and reads from database and shouldn't be hard code.



    I don't have any idea how can I do it .Someone can help me figure out how I can do it ? If you could please point this out, I would be really grateful .










    share|improve this question


























      0












      0








      0


      2






      I want to give ability to admin to active or deactive a module for each store.



      at previous magento version this option was exist under store -> configuration -> advanced -> advanced menue and we could enable or disable a module per store , but from magento 2.2 this option has been removed and no longer avalable.



      according this link for this purpose we have to do some setting manually in our module .



      I want to make setting in my module that admin can see the list of stores and by selecting them to enable or disable a module . for example admin wants to enable module be active for store A and B , and deactive for store C .



      the list of stores should be dynamic and reads from database and shouldn't be hard code.



      I don't have any idea how can I do it .Someone can help me figure out how I can do it ? If you could please point this out, I would be really grateful .










      share|improve this question
















      I want to give ability to admin to active or deactive a module for each store.



      at previous magento version this option was exist under store -> configuration -> advanced -> advanced menue and we could enable or disable a module per store , but from magento 2.2 this option has been removed and no longer avalable.



      according this link for this purpose we have to do some setting manually in our module .



      I want to make setting in my module that admin can see the list of stores and by selecting them to enable or disable a module . for example admin wants to enable module be active for store A and B , and deactive for store C .



      the list of stores should be dynamic and reads from database and shouldn't be hard code.



      I don't have any idea how can I do it .Someone can help me figure out how I can do it ? If you could please point this out, I would be really grateful .







      magento2 multistore magento2.2.2 magento2.3.0






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Apr 24 at 20:13







      Behzad kahvand

















      asked Apr 24 at 18:33









      Behzad kahvandBehzad kahvand

      205




      205




















          1 Answer
          1






          active

          oldest

          votes


















          1














          You can create admin filed using system.xml, then use that field to whatever the location..



          For example..



          By using etc/system.xml



           <group id="general" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
          <label>General Configuration</label>
          <field id="enable" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
          <label>Module Enable</label>
          <source_model>MagentoConfigModelConfigSourceYesno</source_model>
          </field>
          </group>


          Then get this value in helper class



          /*
          * @return bool
          */
          public function isEnabled($scope = ScopeInterface::SCOPE_STORE)

          return (bool) $this->scopeConfig->isSetFlag(
          'additional_registration_fields/general/enable',
          $scope
          );



          then in block you can use as



          public function isEnabled()

          return $this->helperData->isEnabled();



          & final check on view files of frontend:



          <?php if ($block->isEnabled()) : ?>
          // code here if module is enabled for current storeview
          <?php endif; ?>





          share|improve this answer























          • thank you for reply , that's good idea , but I want enable or disable a module for both frontend and adminhtml for specefic stores, and I don't have access to change core magento codes , I want set configuration in my module and these changes apply throughout the store . is there any global variable to hold state of modules in magento that magento checks them for loading modules ?

            – Behzad kahvand
            Apr 25 at 14:39












          • Yes, You can enable/disable whole module by using this method too..

            – Arslan Tabassum
            Apr 25 at 17:01











          • Just add if condition in every controller's execute method like this ... if ($this->helperData->isEnabled() == 'yes' ) // your whole code here

            – Arslan Tabassum
            Apr 25 at 17:34












          • your were right , just one question , how can I use this if condition for prevent load js files ? . I have requirejs-config file that I load some js files instead of core magento js files , how to load these files conditionally ?.

            – Behzad kahvand
            2 days ago












          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
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f272335%2fhow-to-active-deactive-a-module-for-each-store-by-admin-in-magento-2-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









          1














          You can create admin filed using system.xml, then use that field to whatever the location..



          For example..



          By using etc/system.xml



           <group id="general" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
          <label>General Configuration</label>
          <field id="enable" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
          <label>Module Enable</label>
          <source_model>MagentoConfigModelConfigSourceYesno</source_model>
          </field>
          </group>


          Then get this value in helper class



          /*
          * @return bool
          */
          public function isEnabled($scope = ScopeInterface::SCOPE_STORE)

          return (bool) $this->scopeConfig->isSetFlag(
          'additional_registration_fields/general/enable',
          $scope
          );



          then in block you can use as



          public function isEnabled()

          return $this->helperData->isEnabled();



          & final check on view files of frontend:



          <?php if ($block->isEnabled()) : ?>
          // code here if module is enabled for current storeview
          <?php endif; ?>





          share|improve this answer























          • thank you for reply , that's good idea , but I want enable or disable a module for both frontend and adminhtml for specefic stores, and I don't have access to change core magento codes , I want set configuration in my module and these changes apply throughout the store . is there any global variable to hold state of modules in magento that magento checks them for loading modules ?

            – Behzad kahvand
            Apr 25 at 14:39












          • Yes, You can enable/disable whole module by using this method too..

            – Arslan Tabassum
            Apr 25 at 17:01











          • Just add if condition in every controller's execute method like this ... if ($this->helperData->isEnabled() == 'yes' ) // your whole code here

            – Arslan Tabassum
            Apr 25 at 17:34












          • your were right , just one question , how can I use this if condition for prevent load js files ? . I have requirejs-config file that I load some js files instead of core magento js files , how to load these files conditionally ?.

            – Behzad kahvand
            2 days ago
















          1














          You can create admin filed using system.xml, then use that field to whatever the location..



          For example..



          By using etc/system.xml



           <group id="general" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
          <label>General Configuration</label>
          <field id="enable" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
          <label>Module Enable</label>
          <source_model>MagentoConfigModelConfigSourceYesno</source_model>
          </field>
          </group>


          Then get this value in helper class



          /*
          * @return bool
          */
          public function isEnabled($scope = ScopeInterface::SCOPE_STORE)

          return (bool) $this->scopeConfig->isSetFlag(
          'additional_registration_fields/general/enable',
          $scope
          );



          then in block you can use as



          public function isEnabled()

          return $this->helperData->isEnabled();



          & final check on view files of frontend:



          <?php if ($block->isEnabled()) : ?>
          // code here if module is enabled for current storeview
          <?php endif; ?>





          share|improve this answer























          • thank you for reply , that's good idea , but I want enable or disable a module for both frontend and adminhtml for specefic stores, and I don't have access to change core magento codes , I want set configuration in my module and these changes apply throughout the store . is there any global variable to hold state of modules in magento that magento checks them for loading modules ?

            – Behzad kahvand
            Apr 25 at 14:39












          • Yes, You can enable/disable whole module by using this method too..

            – Arslan Tabassum
            Apr 25 at 17:01











          • Just add if condition in every controller's execute method like this ... if ($this->helperData->isEnabled() == 'yes' ) // your whole code here

            – Arslan Tabassum
            Apr 25 at 17:34












          • your were right , just one question , how can I use this if condition for prevent load js files ? . I have requirejs-config file that I load some js files instead of core magento js files , how to load these files conditionally ?.

            – Behzad kahvand
            2 days ago














          1












          1








          1







          You can create admin filed using system.xml, then use that field to whatever the location..



          For example..



          By using etc/system.xml



           <group id="general" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
          <label>General Configuration</label>
          <field id="enable" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
          <label>Module Enable</label>
          <source_model>MagentoConfigModelConfigSourceYesno</source_model>
          </field>
          </group>


          Then get this value in helper class



          /*
          * @return bool
          */
          public function isEnabled($scope = ScopeInterface::SCOPE_STORE)

          return (bool) $this->scopeConfig->isSetFlag(
          'additional_registration_fields/general/enable',
          $scope
          );



          then in block you can use as



          public function isEnabled()

          return $this->helperData->isEnabled();



          & final check on view files of frontend:



          <?php if ($block->isEnabled()) : ?>
          // code here if module is enabled for current storeview
          <?php endif; ?>





          share|improve this answer













          You can create admin filed using system.xml, then use that field to whatever the location..



          For example..



          By using etc/system.xml



           <group id="general" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
          <label>General Configuration</label>
          <field id="enable" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
          <label>Module Enable</label>
          <source_model>MagentoConfigModelConfigSourceYesno</source_model>
          </field>
          </group>


          Then get this value in helper class



          /*
          * @return bool
          */
          public function isEnabled($scope = ScopeInterface::SCOPE_STORE)

          return (bool) $this->scopeConfig->isSetFlag(
          'additional_registration_fields/general/enable',
          $scope
          );



          then in block you can use as



          public function isEnabled()

          return $this->helperData->isEnabled();



          & final check on view files of frontend:



          <?php if ($block->isEnabled()) : ?>
          // code here if module is enabled for current storeview
          <?php endif; ?>






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Apr 25 at 0:48









          Arslan TabassumArslan Tabassum

          1466




          1466












          • thank you for reply , that's good idea , but I want enable or disable a module for both frontend and adminhtml for specefic stores, and I don't have access to change core magento codes , I want set configuration in my module and these changes apply throughout the store . is there any global variable to hold state of modules in magento that magento checks them for loading modules ?

            – Behzad kahvand
            Apr 25 at 14:39












          • Yes, You can enable/disable whole module by using this method too..

            – Arslan Tabassum
            Apr 25 at 17:01











          • Just add if condition in every controller's execute method like this ... if ($this->helperData->isEnabled() == 'yes' ) // your whole code here

            – Arslan Tabassum
            Apr 25 at 17:34












          • your were right , just one question , how can I use this if condition for prevent load js files ? . I have requirejs-config file that I load some js files instead of core magento js files , how to load these files conditionally ?.

            – Behzad kahvand
            2 days ago


















          • thank you for reply , that's good idea , but I want enable or disable a module for both frontend and adminhtml for specefic stores, and I don't have access to change core magento codes , I want set configuration in my module and these changes apply throughout the store . is there any global variable to hold state of modules in magento that magento checks them for loading modules ?

            – Behzad kahvand
            Apr 25 at 14:39












          • Yes, You can enable/disable whole module by using this method too..

            – Arslan Tabassum
            Apr 25 at 17:01











          • Just add if condition in every controller's execute method like this ... if ($this->helperData->isEnabled() == 'yes' ) // your whole code here

            – Arslan Tabassum
            Apr 25 at 17:34












          • your were right , just one question , how can I use this if condition for prevent load js files ? . I have requirejs-config file that I load some js files instead of core magento js files , how to load these files conditionally ?.

            – Behzad kahvand
            2 days ago

















          thank you for reply , that's good idea , but I want enable or disable a module for both frontend and adminhtml for specefic stores, and I don't have access to change core magento codes , I want set configuration in my module and these changes apply throughout the store . is there any global variable to hold state of modules in magento that magento checks them for loading modules ?

          – Behzad kahvand
          Apr 25 at 14:39






          thank you for reply , that's good idea , but I want enable or disable a module for both frontend and adminhtml for specefic stores, and I don't have access to change core magento codes , I want set configuration in my module and these changes apply throughout the store . is there any global variable to hold state of modules in magento that magento checks them for loading modules ?

          – Behzad kahvand
          Apr 25 at 14:39














          Yes, You can enable/disable whole module by using this method too..

          – Arslan Tabassum
          Apr 25 at 17:01





          Yes, You can enable/disable whole module by using this method too..

          – Arslan Tabassum
          Apr 25 at 17:01













          Just add if condition in every controller's execute method like this ... if ($this->helperData->isEnabled() == 'yes' ) // your whole code here

          – Arslan Tabassum
          Apr 25 at 17:34






          Just add if condition in every controller's execute method like this ... if ($this->helperData->isEnabled() == 'yes' ) // your whole code here

          – Arslan Tabassum
          Apr 25 at 17:34














          your were right , just one question , how can I use this if condition for prevent load js files ? . I have requirejs-config file that I load some js files instead of core magento js files , how to load these files conditionally ?.

          – Behzad kahvand
          2 days ago






          your were right , just one question , how can I use this if condition for prevent load js files ? . I have requirejs-config file that I load some js files instead of core magento js files , how to load these files conditionally ?.

          – Behzad kahvand
          2 days ago


















          draft saved

          draft discarded
















































          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.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f272335%2fhow-to-active-deactive-a-module-for-each-store-by-admin-in-magento-2-2%23new-answer', 'question_page');

          );

          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







          Popular posts from this blog

          Bulk add to cart function issuecart vs. mini cart issue … rwd themeRedirect Add to cart button to cart pageAdd to cart issue - Magento 2.1The requested Payment Method is not available When creating an orderM2: reason add-to-cart might not function in production modeAdd to cart issue in some android devicesMagento 2 - custom price can not add to subtotal and grand total after add to cartAdd to cart codeIssue with my cart module on pdp and cart pages, just keeps spinningBulk price and quantity update using rest api

          БиармияSxpst500bh2ntaf! 3h2r