I have created an event sales_order_place_before. But it's not working.

You can see my code here :


<?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="sales_order_place_before">
      <observer name="Test_Inquiry_sales_order_place_before"  

Here is observer code:


namespace Test\Inquiry\Observer;

use Magento\Framework\Event\ObserverInterface;

class OrderPlacebefore implements ObserverInterface
 protected $_objectManager;

  public function __construct(
    \Magento\Framework\ObjectManagerInterface $objectManager
  ) {
      $this->_objectManager = $objectManager;

  public function execute(\Magento\Framework\Event\Observer $observer)
       echo  "Hello Testing ";die();

Can you please help me to resolve the issue ?

  • Make sure this module works. And then, try clear your Magento Cache. Aug 31 '16 at 13:00
  • Yes, I am dem sure this module is work and also i have cleared cache and indexing.but still not working. Aug 31 '16 at 13:07
  • current issue is observer not working if i put events,xml outside frontend folder than observer is working but redirecting automatically on cart page and if i put events.xml in frontend folder than it's not working. Aug 31 '16 at 13:56
  • How about your current issue? Sep 3 '16 at 14:07

Put your events.xml file outside the frontend folder.


If we put the events.xml under etc/frontend. It may not work. I'm not sure that it may be a bug.

  • I have already put in etc/frontend. Aug 31 '16 at 13:10
  • Put your event.xml file outside the frontend folder. Aug 31 '16 at 13:11
  • Now i got the message in observer but it's redirect the page automatically on cart page. can you please suggest what the issue. This issue occuring after put my event.xml file outside in frontend folder. can you please suggest me what can i do ? Aug 31 '16 at 13:47
  • 1
    This is normal because you tried to die the checkout process. I think your observer can work now! Aug 31 '16 at 14:12
  • 1
    If your observer can work, so, your current issue solved, please accept the answer. Aug 31 '16 at 14:18


You should put you events.xml in webapi_rest folder. Path will be etc/webapi_rest/events.xml. It will work.

Actually It was magento internal issue. They have resolved it. Look Here

  • It is working fine Jul 29 '19 at 6:48
  • Thanks, that was indeed working! But how to figure something like this out?? I will never use observers again, from now on I will only use plugins...
    – Black
    Nov 16 '20 at 17:21

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.