1

magento_root\vendor\magento\module-config\Controller\Adminhtml\System\Config\Save.php

how can i override this controller in the magento 2

0

Hello for this you have to extend default controller through dependency injection

<?xml version="1.0"?>

 <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">

<preference for="Magento\Config\Controller\Adminhtml\Product\Edit\Adminhtml\System\Config\Save" type="Sample\HelloWorld\Controller\Adminhtml\System\Config\Save" />

 </config>

you can use and define your code in your own controller like

    <?php
    namespace Sample\HelloWorld\Controller\Adminhtml\System\Config;

    class Save extends \Magento\Config\Controller\Adminhtml\Product\Edit\Adminhtml\System\Config\Save
    {
     public function execute()
     {
     $this->messageManager->addSuccess('Message from new admin controller.');
     return parent::execute();
     }
    } 
  • 1
    Thanks for your help.. But how to get parameters before save config in custom shipping module. – Rahul Katoch Mar 24 '17 at 14:02
  • $this->getRequestParams(); – ravichandra Jan 18 at 16:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.