/** * @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); } }
/** * Update all child and parent order's edit increment numbers. * Needed for Admin area. * * @param \Magento\Sales\Model\Order $order * @return void */ public function updateOrderEditIncrements(\Magento\Sales\Model\Order $order) { if ($order->getId() && $order->getOriginalIncrementId()) { $collection = $order->getCollection(); $quotedIncrId = $collection->getConnection()->quote($order->getOriginalIncrementId()); $collection->getSelect()->where("original_increment_id = {$quotedIncrId} OR increment_id = {$quotedIncrId}"); foreach ($collection as $orderToUpdate) { $orderToUpdate->setEditIncrement($order->getEditIncrement()); $orderToUpdate->save(); } } }