save data from a module if save config buton is click in admin configurationwhat is the event in magento 2...

How can bays and straits be determined in a procedurally generated map?

Are astronomers waiting to see something in an image from a gravitational lens that they've already seen in an adjacent image?

A newer friend of my brother's gave him a load of baseball cards that are supposedly extremely valuable. Is this a scam?

Convert two switches to a dual stack, and add outlet - possible here?

How do I deal with an unproductive colleague in a small company?

What's the point of deactivating Num Lock on login screens?

Why does Kotter return in Welcome Back Kotter?

"You are your self first supporter", a more proper way to say it

Arrow those variables!

Why do I get two different answers for this counting problem?

Why can't I see bouncing of a switch on an oscilloscope?

Character reincarnated...as a snail

How can I prevent hyper evolved versions of regular creatures from wiping out their cousins?

Is it inappropriate for a student to attend their mentor's dissertation defense?

How can I make my BBEG immortal short of making them a Lich or Vampire?

dbcc cleantable batch size explanation

Today is the Center

Is it possible to do 50 km distance without any previous training?

Alternative to sending password over mail?

Has there ever been an airliner design involving reducing generator load by installing solar panels?

How is the claim "I am in New York only if I am in America" the same as "If I am in New York, then I am in America?

tikz convert color string to hex value

Can you really stack all of this on an Opportunity Attack?

Does an object always see its latest internal state irrespective of thread?



save data from a module if save config buton is click in admin configuration


what is the event in magento 2 when store configuration save?Don't get data saved in my configurationPossible raw SQL statement detectedMagento 2 :Admin ConfigurationMagento 2: Get admin config valuesMagento2 : How to save system config programmaticallyGet config value for specific store from admin areaGet configuration for custom moduleMagento 2 : Error when i click the admin->configurationMagento2.2.3 - Admin store configuration is save but not display in admin panelHow to Save custom data from admin->system->configuration magento 1.9






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







0















save data from a module in database if save config button is click in admin configuration. Basically I want to disabled a module if disabled from admin. Actually disable functionality is not working. So I trying disabled module pro grammatically I have created a controller with update query but this works when I hit the controller in front end. Basically My query disable module from general but my query will disable from advance/advance.



Path of controller - Vendor/Module/Controller/index/index.php



function in controller that I trying to update :-



public function execute()
{
$objectManager = MagentoFrameworkAppObjectManager::getInstance(); // Instance of object manager
$resource = $objectManager->get('MagentoFrameworkAppResourceConnection');
$connection = $resource->getConnection();
$tableName = $resource->getTableName('core_config_data');
echo $isEnabled = $this->helperData->isEnable();

if ($isEnabled==1) {
//gives table name with prefix

//Select Data from table
echo $sql = "Update " . $tableName . " Set value = 0 where path ='advanced/modules_disable_output/Vendor_Module'";
$connection->query($sql);

}

//return $result->setData($methods);

else {
echo $sql = "Update " . $tableName . " Set value = 1 where path ='advanced/modules_disable_output/Vendor_Module'";
$connection->query($sql);

}
}









share|improve this question
















bumped to the homepage by Community 27 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.






















    0















    save data from a module in database if save config button is click in admin configuration. Basically I want to disabled a module if disabled from admin. Actually disable functionality is not working. So I trying disabled module pro grammatically I have created a controller with update query but this works when I hit the controller in front end. Basically My query disable module from general but my query will disable from advance/advance.



    Path of controller - Vendor/Module/Controller/index/index.php



    function in controller that I trying to update :-



    public function execute()
    {
    $objectManager = MagentoFrameworkAppObjectManager::getInstance(); // Instance of object manager
    $resource = $objectManager->get('MagentoFrameworkAppResourceConnection');
    $connection = $resource->getConnection();
    $tableName = $resource->getTableName('core_config_data');
    echo $isEnabled = $this->helperData->isEnable();

    if ($isEnabled==1) {
    //gives table name with prefix

    //Select Data from table
    echo $sql = "Update " . $tableName . " Set value = 0 where path ='advanced/modules_disable_output/Vendor_Module'";
    $connection->query($sql);

    }

    //return $result->setData($methods);

    else {
    echo $sql = "Update " . $tableName . " Set value = 1 where path ='advanced/modules_disable_output/Vendor_Module'";
    $connection->query($sql);

    }
    }









    share|improve this question
















    bumped to the homepage by Community 27 mins ago


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.


















      0












      0








      0


      0






      save data from a module in database if save config button is click in admin configuration. Basically I want to disabled a module if disabled from admin. Actually disable functionality is not working. So I trying disabled module pro grammatically I have created a controller with update query but this works when I hit the controller in front end. Basically My query disable module from general but my query will disable from advance/advance.



      Path of controller - Vendor/Module/Controller/index/index.php



      function in controller that I trying to update :-



      public function execute()
      {
      $objectManager = MagentoFrameworkAppObjectManager::getInstance(); // Instance of object manager
      $resource = $objectManager->get('MagentoFrameworkAppResourceConnection');
      $connection = $resource->getConnection();
      $tableName = $resource->getTableName('core_config_data');
      echo $isEnabled = $this->helperData->isEnable();

      if ($isEnabled==1) {
      //gives table name with prefix

      //Select Data from table
      echo $sql = "Update " . $tableName . " Set value = 0 where path ='advanced/modules_disable_output/Vendor_Module'";
      $connection->query($sql);

      }

      //return $result->setData($methods);

      else {
      echo $sql = "Update " . $tableName . " Set value = 1 where path ='advanced/modules_disable_output/Vendor_Module'";
      $connection->query($sql);

      }
      }









      share|improve this question
















      save data from a module in database if save config button is click in admin configuration. Basically I want to disabled a module if disabled from admin. Actually disable functionality is not working. So I trying disabled module pro grammatically I have created a controller with update query but this works when I hit the controller in front end. Basically My query disable module from general but my query will disable from advance/advance.



      Path of controller - Vendor/Module/Controller/index/index.php



      function in controller that I trying to update :-



      public function execute()
      {
      $objectManager = MagentoFrameworkAppObjectManager::getInstance(); // Instance of object manager
      $resource = $objectManager->get('MagentoFrameworkAppResourceConnection');
      $connection = $resource->getConnection();
      $tableName = $resource->getTableName('core_config_data');
      echo $isEnabled = $this->helperData->isEnable();

      if ($isEnabled==1) {
      //gives table name with prefix

      //Select Data from table
      echo $sql = "Update " . $tableName . " Set value = 0 where path ='advanced/modules_disable_output/Vendor_Module'";
      $connection->query($sql);

      }

      //return $result->setData($methods);

      else {
      echo $sql = "Update " . $tableName . " Set value = 1 where path ='advanced/modules_disable_output/Vendor_Module'";
      $connection->query($sql);

      }
      }






      magento2 system-config ifconfig






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 25 '18 at 13:25









      Purushotam Sharma

      8651730




      8651730










      asked Feb 23 '18 at 10:40









      Aman DeepAman Deep

      13




      13





      bumped to the homepage by Community 27 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community 27 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
























          1 Answer
          1






          active

          oldest

          votes


















          0














          You can achieve what you want to do by either using observer or plugin as follows ;



          Following event are fire after System->configuration Save.



          admin_system_config_changed_section_{$section} -> here $section is 'general' etc.



          Here is an example for 'admin_system_config_changed_section_general' event.



          etc/events.xml





          <?xml version="1.0" encoding="UTF-8"?>
          <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
          <event name="admin_system_config_changed_section_general">
          <observer name="custom_admin_system_config_changed_section_general" instance="[Vendor][Module]ObserverConfigObserver"/>
          </event>
          </config>



          and observer class is "[Vendor][Module]ObserverConfigObserver"





          namespace [Vendor][Module]Observer;

          use MagentoFrameworkEventObserverInterface;
          use MagentoFrameworkEventObserver as EventObserver;
          use PsrLogLoggerInterface as Logger;

          class ConfigObserver implements ObserverInterface
          {
          /**
          * @var Logger
          */
          protected $logger;

          /**
          * @param Logger $logger
          */
          public function __construct(
          Logger $logger
          ) {
          $this->logger = $logger;
          }

          public function execute(EventObserver $observer)
          {
          //$this->logger->info($observer->getWebsite());
          //$this->logger->info($observer->getStore());
          }
          }



          You can do this same thing using plugin.
          Create di.xml "etc/di.xml"





          <?xml version="1.0"?>
          <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
          <type name="MagentoConfigModelConfig">
          <plugin name="admin_system_config_save_plugin" type="[Vendor][Module]PluginConfigPlugin" sortOrder="1"/>
          </type>
          </config>



          And Plugin class '[Vendor][Module]/Plugin/ConfigPlugin.php'





          namespace [Vendor][Module]Plugin;


          class ConfigPlugin
          {
          public function aroundSave(
          MagentoConfigModelConfig $subject,
          Closure $proceed
          ) {
          // your custom logic
          return $proceed();
          }
          }



          Reference : what is the event in magento 2 when store configuration save?






          share|improve this answer


























            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%2f214773%2fsave-data-from-a-module-if-save-config-buton-is-click-in-admin-configuration%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









            0














            You can achieve what you want to do by either using observer or plugin as follows ;



            Following event are fire after System->configuration Save.



            admin_system_config_changed_section_{$section} -> here $section is 'general' etc.



            Here is an example for 'admin_system_config_changed_section_general' event.



            etc/events.xml





            <?xml version="1.0" encoding="UTF-8"?>
            <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
            <event name="admin_system_config_changed_section_general">
            <observer name="custom_admin_system_config_changed_section_general" instance="[Vendor][Module]ObserverConfigObserver"/>
            </event>
            </config>



            and observer class is "[Vendor][Module]ObserverConfigObserver"





            namespace [Vendor][Module]Observer;

            use MagentoFrameworkEventObserverInterface;
            use MagentoFrameworkEventObserver as EventObserver;
            use PsrLogLoggerInterface as Logger;

            class ConfigObserver implements ObserverInterface
            {
            /**
            * @var Logger
            */
            protected $logger;

            /**
            * @param Logger $logger
            */
            public function __construct(
            Logger $logger
            ) {
            $this->logger = $logger;
            }

            public function execute(EventObserver $observer)
            {
            //$this->logger->info($observer->getWebsite());
            //$this->logger->info($observer->getStore());
            }
            }



            You can do this same thing using plugin.
            Create di.xml "etc/di.xml"





            <?xml version="1.0"?>
            <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
            <type name="MagentoConfigModelConfig">
            <plugin name="admin_system_config_save_plugin" type="[Vendor][Module]PluginConfigPlugin" sortOrder="1"/>
            </type>
            </config>



            And Plugin class '[Vendor][Module]/Plugin/ConfigPlugin.php'





            namespace [Vendor][Module]Plugin;


            class ConfigPlugin
            {
            public function aroundSave(
            MagentoConfigModelConfig $subject,
            Closure $proceed
            ) {
            // your custom logic
            return $proceed();
            }
            }



            Reference : what is the event in magento 2 when store configuration save?






            share|improve this answer






























              0














              You can achieve what you want to do by either using observer or plugin as follows ;



              Following event are fire after System->configuration Save.



              admin_system_config_changed_section_{$section} -> here $section is 'general' etc.



              Here is an example for 'admin_system_config_changed_section_general' event.



              etc/events.xml





              <?xml version="1.0" encoding="UTF-8"?>
              <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
              <event name="admin_system_config_changed_section_general">
              <observer name="custom_admin_system_config_changed_section_general" instance="[Vendor][Module]ObserverConfigObserver"/>
              </event>
              </config>



              and observer class is "[Vendor][Module]ObserverConfigObserver"





              namespace [Vendor][Module]Observer;

              use MagentoFrameworkEventObserverInterface;
              use MagentoFrameworkEventObserver as EventObserver;
              use PsrLogLoggerInterface as Logger;

              class ConfigObserver implements ObserverInterface
              {
              /**
              * @var Logger
              */
              protected $logger;

              /**
              * @param Logger $logger
              */
              public function __construct(
              Logger $logger
              ) {
              $this->logger = $logger;
              }

              public function execute(EventObserver $observer)
              {
              //$this->logger->info($observer->getWebsite());
              //$this->logger->info($observer->getStore());
              }
              }



              You can do this same thing using plugin.
              Create di.xml "etc/di.xml"





              <?xml version="1.0"?>
              <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
              <type name="MagentoConfigModelConfig">
              <plugin name="admin_system_config_save_plugin" type="[Vendor][Module]PluginConfigPlugin" sortOrder="1"/>
              </type>
              </config>



              And Plugin class '[Vendor][Module]/Plugin/ConfigPlugin.php'





              namespace [Vendor][Module]Plugin;


              class ConfigPlugin
              {
              public function aroundSave(
              MagentoConfigModelConfig $subject,
              Closure $proceed
              ) {
              // your custom logic
              return $proceed();
              }
              }



              Reference : what is the event in magento 2 when store configuration save?






              share|improve this answer




























                0












                0








                0







                You can achieve what you want to do by either using observer or plugin as follows ;



                Following event are fire after System->configuration Save.



                admin_system_config_changed_section_{$section} -> here $section is 'general' etc.



                Here is an example for 'admin_system_config_changed_section_general' event.



                etc/events.xml





                <?xml version="1.0" encoding="UTF-8"?>
                <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
                <event name="admin_system_config_changed_section_general">
                <observer name="custom_admin_system_config_changed_section_general" instance="[Vendor][Module]ObserverConfigObserver"/>
                </event>
                </config>



                and observer class is "[Vendor][Module]ObserverConfigObserver"





                namespace [Vendor][Module]Observer;

                use MagentoFrameworkEventObserverInterface;
                use MagentoFrameworkEventObserver as EventObserver;
                use PsrLogLoggerInterface as Logger;

                class ConfigObserver implements ObserverInterface
                {
                /**
                * @var Logger
                */
                protected $logger;

                /**
                * @param Logger $logger
                */
                public function __construct(
                Logger $logger
                ) {
                $this->logger = $logger;
                }

                public function execute(EventObserver $observer)
                {
                //$this->logger->info($observer->getWebsite());
                //$this->logger->info($observer->getStore());
                }
                }



                You can do this same thing using plugin.
                Create di.xml "etc/di.xml"





                <?xml version="1.0"?>
                <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
                <type name="MagentoConfigModelConfig">
                <plugin name="admin_system_config_save_plugin" type="[Vendor][Module]PluginConfigPlugin" sortOrder="1"/>
                </type>
                </config>



                And Plugin class '[Vendor][Module]/Plugin/ConfigPlugin.php'





                namespace [Vendor][Module]Plugin;


                class ConfigPlugin
                {
                public function aroundSave(
                MagentoConfigModelConfig $subject,
                Closure $proceed
                ) {
                // your custom logic
                return $proceed();
                }
                }



                Reference : what is the event in magento 2 when store configuration save?






                share|improve this answer















                You can achieve what you want to do by either using observer or plugin as follows ;



                Following event are fire after System->configuration Save.



                admin_system_config_changed_section_{$section} -> here $section is 'general' etc.



                Here is an example for 'admin_system_config_changed_section_general' event.



                etc/events.xml





                <?xml version="1.0" encoding="UTF-8"?>
                <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
                <event name="admin_system_config_changed_section_general">
                <observer name="custom_admin_system_config_changed_section_general" instance="[Vendor][Module]ObserverConfigObserver"/>
                </event>
                </config>



                and observer class is "[Vendor][Module]ObserverConfigObserver"





                namespace [Vendor][Module]Observer;

                use MagentoFrameworkEventObserverInterface;
                use MagentoFrameworkEventObserver as EventObserver;
                use PsrLogLoggerInterface as Logger;

                class ConfigObserver implements ObserverInterface
                {
                /**
                * @var Logger
                */
                protected $logger;

                /**
                * @param Logger $logger
                */
                public function __construct(
                Logger $logger
                ) {
                $this->logger = $logger;
                }

                public function execute(EventObserver $observer)
                {
                //$this->logger->info($observer->getWebsite());
                //$this->logger->info($observer->getStore());
                }
                }



                You can do this same thing using plugin.
                Create di.xml "etc/di.xml"





                <?xml version="1.0"?>
                <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
                <type name="MagentoConfigModelConfig">
                <plugin name="admin_system_config_save_plugin" type="[Vendor][Module]PluginConfigPlugin" sortOrder="1"/>
                </type>
                </config>



                And Plugin class '[Vendor][Module]/Plugin/ConfigPlugin.php'





                namespace [Vendor][Module]Plugin;


                class ConfigPlugin
                {
                public function aroundSave(
                MagentoConfigModelConfig $subject,
                Closure $proceed
                ) {
                // your custom logic
                return $proceed();
                }
                }



                Reference : what is the event in magento 2 when store configuration save?







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Jan 23 at 8:10









                magefms

                2,3872426




                2,3872426










                answered Feb 24 '18 at 12:51









                Vivek KumarVivek Kumar

                2,5772729




                2,5772729






























                    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%2f214773%2fsave-data-from-a-module-if-save-config-buton-is-click-in-admin-configuration%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

                    “%fieldName is a required field.”, in Magento2 REST API Call for GET Method Type The Next...

                    How to change City field to a dropdown in Checkout step Magento 2Magento 2 : How to change UI field(s)...

                    夢乃愛華...