magento2 - Magento 2 observer event not triggering -


i have added observer module , put event definition in events.xml

# app/code/vendor/modulename/etc/frontend/events.xml  <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:nonamespaceschemalocation="urn:magento:framework:event/etc/events.xsd">     <event name="checkout_submit_before">         <observer name="vendor_modulename_order_save_before" instance="vendor\modulename\observer\orderobserver" />     </event> </config> 

i have added logic in observer

# app/code/vendor/name/observer/orderobserver.php namespace vendor\modulename\observer;  use magento\framework\event\observer; use magento\framework\event\observerinterface;  class orderobserver implements observerinterface {      public function __construct()     {     }      /**      * @param observer $observer      * @return void      */     public function execute(\magento\framework\event\observer $observer)     {         $quote = $observer->getquote();         ...         ...         ...     } } 

try placing events.xml etc/events.xml

# app/code/vendor/modulename/etc/events.xml  <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:nonamespaceschemalocation="urn:magento:framework:event/etc/events.xsd">     <event name="checkout_submit_before">         <observer name="vendor_modulename_order_save_before" instance="vendor\modulename\observer\orderobserver" />     </event> </config> 

and no need use magento\framework\event\observer

# app/code/vendor/modulename/observer/orderobserver.php namespace vendor\modulename\observer; use magento\framework\event\observerinterface;  class orderobserver implements observerinterface {     /**      * @param observer $observer      * @return void      */     public function execute(\magento\framework\event\observer $observer)     {         $quote = $observer->getquote();         ...         ...         ...     } } 

make sure clean cache

bin/magento cache:clean 

let me know if still having issues


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -