0

I want to show a message in back-end when shipping settings getting changed.

For example, If i add Flat Rate -> Handling Fee more than 5 it should show a div just near like "Entered amount in higher".

Any help will be highly appreciated.

  • @Rama Chandran: Any idea on this? – mujuonly Jun 14 '17 at 8:22
0

You should go with below observer event

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

Create event xml file like in 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_carriers">
        <observer name="custom_admin_system_config_changed_section_carriers" instance="[Vendor]\[Module]\Observer\ConfigObserver"/>
    </event>
</config>

and observer class is "[Vendor][Module]\Observer\ConfigObserver".

namespace [Vendor]\[Module]\Observer;
use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\Event\Observer as EventObserver;
use Psr\Log\LoggerInterface 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)
    {
        //write your logic and magento notification message here
    }

}

You can check below link to get more ideas and alternate options.

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

  • I need to show a message with onchange event of a settings. Not showing a message after saving. Any idea on that – mujuonly Jun 14 '17 at 9:03
  • if you want to fire validation before save, You can assign backend model in system config field. So method throw exceptions if something is wrong and the config won't be saved. – Prashant Gohil Jun 14 '17 at 9:11
  • Not validation. Just show a message ( div or alert ) when changing one settings. Still they can save ( But just show a warning ) Any idea? – mujuonly Jun 14 '17 at 9:12

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.