0

I have an observer, which is working fine (after some effort on what is a Frankenstein website). However when I attempt to use my class in my construct it causes a 500 error (mode is developer, but no useful logs are being created, and the error stated is to do with the guest checkout) - if I remove the class from the construct then the observer works.

<?php

namespace MyVendor\Order\Observer;

use \Magento\Framework\Event\Observer;
use \Magento\Framework\Event\ObserverInterface;
use \Psr\Log\LoggerInterface;

class OrderObserver implements ObserverInterface
{
    protected $logger;
    protected $exporter;

    public function __construct(
        LoggerInterface $logger,
        \MyVendor\Order\Model\Exporter $exporter
    ){
        $this->logger = $logger;
        $this->exporter = $exporter;
    }

    public function execute(Observer $observer)
    {
        //Observer execution code...
        $this->logger->debug('MyVendor-Observer');
        //$this->exporter->orderPlacedObserver($observer);
    }
}

There does not seem to be any error with setup:di:compile (not that this needs running in developer mode I know) - so how would I debug this issue and use my other class within the Observer?

0

You need to find out what the error is.

If nothing is being logged by Magento, check your server error logs. By default, PHP error messages get logged there.

I would also check the dependencies in your Exporter class, because it seems Magento cannot instantiate all the dependencies declared in you Exporter class without a problem occurring.

  • 1
    exception.log is not being updated at all yes, I'll check the server logs and the Exporter dependencies. – Aravona Jun 28 '18 at 14:03

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.