I have an event Observer for sales_order_place_after
namespace Company\Ordertool\Observer;
use Magento\Framework\Event\ObserverInterface;
class OrderComplete implements ObserverInterface
{
/**
* @var ObjectManagerInterface
*/
protected $_objectManager;
/**
* @param \Magento\Framework\ObjectManagerInterface $objectManager
*/
public function __construct(
\Magento\Framework\ObjectManagerInterface $objectManager,
\Magento\Quote\Model\QuoteFactory $quoteFactory,
\Magento\Sales\Model\Order $order
) {
$this->_objectManager = $objectManager;
$this->order = $order;
}
/**
*
* @param \Magento\Framework\Event\Observer $observer
* @return void
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
$order = $observer->getEvent()->getOrder();
$orderId = $order->getId();
$writer = new \Zend\Log\Writer\Stream(BP . '/var/log/debug.log');
$logger = new \Zend\Log\Logger();
$logger->addWriter($writer);
$logger->info( $orderId );
}
}
$order does appear to be the order ... but $orderId is empty. I feel like I'm missing something obvious here...