Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ReportOrderPlacedToNewRelic.php
Go to the documentation of this file.
1 <?php
7 
12 
17 {
21  protected $config;
22 
26  protected $newRelicWrapper;
27 
32  public function __construct(
35  ) {
36  $this->config = $config;
37  $this->newRelicWrapper = $newRelicWrapper;
38  }
39 
46  public function execute(Observer $observer)
47  {
48  if ($this->config->isNewRelicEnabled()) {
50  $order = $observer->getEvent()->getOrder();
51  $itemCount = $order->getTotalItemCount();
52  if (!is_numeric($itemCount) && empty($itemCount)) {
53  $itemCount = $order->getTotalQtyOrdered();
54  }
55 
56  $this->newRelicWrapper->addCustomParameter(Config::ORDER_PLACED, 1);
57  $this->newRelicWrapper->addCustomParameter(Config::ORDER_ITEMS, $itemCount);
58  $this->newRelicWrapper->addCustomParameter(Config::ORDER_VALUE, $order->getBaseGrandTotal());
59  }
60  }
61 }
$order
Definition: order.php:55