33 lines
932 B
PHP
Executable File
33 lines
932 B
PHP
Executable File
<?php
|
|
namespace IpSupply\OrderEvent\Observer;
|
|
use Magento\Framework\Event\ObserverInterface;
|
|
|
|
class CheckOrderStatus implements ObserverInterface {
|
|
|
|
protected $orderRepository;
|
|
protected $dir;
|
|
|
|
public function __construct(
|
|
\Magento\Sales\Api\OrderRepositoryInterface $orderRepository,
|
|
\Magento\Framework\Filesystem\DirectoryList $dir,
|
|
)
|
|
{
|
|
$this->orderRepository = $orderRepository;
|
|
$this->dir = $dir;
|
|
}
|
|
|
|
public function execute(\Magento\Framework\Event\Observer $observer) {
|
|
$order = $observer->getEvent()->getOrder();
|
|
$customerId = $order->getCustomerId();
|
|
$OrderStatus=$order->getStatus();
|
|
$file = $this->dir->getPath('log').'/'.'CheckOrderStatus.log';
|
|
if (!file_exists($file)) {
|
|
$fh = fopen($file, 'w') or die("Can't create file");
|
|
fclose($fh);
|
|
}
|
|
$current = file_get_contents($file);
|
|
$current .= $OrderStatus." \n";
|
|
file_put_contents($file, $current);
|
|
}
|
|
}
|