예제 #1
0
 /**
  * @param $event
  * @throws \Exception
  */
 private function onOrderSuccessPageView($event)
 {
     try {
         $orders = $this->order->getCollection()->setOrder('entity_id', 'DESC')->setPageSize(1)->setCurPage(1);
         $order = $orders->getFirstItem();
         $orderData = $order->getData();
         $transactionId = $orderData['entity_id'];
         $products = array();
         foreach ($order->getAllItems() as $item) {
             if ($item->getPrice() > 0) {
                 $products[] = array('product' => $item->getProduct()->getId(), 'quantity' => $item->getData('qty_ordered'), 'price' => $item->getPrice());
             }
         }
         $fullPrice = $orderData['grand_total'];
         $currency = $orderData['base_currency_code'];
         $script = $this->bxHelperData->reportPurchase($products, $transactionId, $fullPrice, $currency);
         $this->addScript($script);
     } catch (\Exception $e) {
         $this->_logger->critical($e);
     }
 }