I am trying to make an observer which on order confirmation, prints This Works in debug.log file.

When clicking on Place Order in checkout, the Observer gives 500 Internal Server Error with this in console with this in the error log:

<b>Fatal error</b>:  Class 'My/Plugin/Observer/Dummy' not found in <b>/var/www/html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php</b> on line <b>97</b>

Also, my checkout hangs when clicked on Place Order.

My app/code/My/Plugin/Observer/Dummy.php File:


namespace My\Plugin\Observer;

use Magento\Framework\Event\ObserverInterface;

class Dummy implements ObserverInterface

    protected $_logger;

    public function __construct(
        \Psr\Log\LoggerInterface $logger,
        array $data = []
    ) {
        $this->_logger = $logger;

    public function execute(\Magento\Framework\Event\Observer $observer)    {
        $event = $observer->getEvent();
            $quote = $event->getQuote();
        $myfile = fopen("var/log/debug.log", "a+") or die("Unable to open file!");
        fwrite($myfile, print("This Works"));

My app/code/My/Plugin/etc/events.xml File:

<?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="sales_order_save_commit_after">
        <observer name="my_sales_observer" instance="My/Plugin/Observer/Dummy" />

Any Idea where am I doing wrong??

  • I assume My/Plugin is just a placeholder for Infinia/SalesOrder or that's how the files are named in your code?
    – Marius
    May 16 '16 at 13:53
  • Yes, its right.... its just a placeholder May 16 '16 at 14:19

Well your observer path looks wrong to me.

Instead of


It should be:

  • Tried that.... still gives the same error :( May 16 '16 at 14:18
  • I changed the namespace in php file and path in xml file to xml instance: My/Plugin/Observer/Dummy php namespace: My\Plugin\Observer Is it wrong?? May 16 '16 at 14:27

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.