/** * @param Order $order * @return bool */ protected function isProcessingAllowed(Order $order) { $isProcessingAllowed = true; $customer = $this->findExistingEntity($order->getCustomer()); $customerOriginId = $order->getCustomer()->getOriginId(); if (!$customer && $customerOriginId) { $this->appendDataToContext(ContextCustomerReader::CONTEXT_POST_PROCESS_CUSTOMERS, $customerOriginId); $isProcessingAllowed = false; } // Do not try to load cart if bridge does not installed /** @var MagentoSoapTransport $transport */ $channel = $this->databaseHelper->findOneByIdentity($order->getChannel()); $transport = $channel->getTransport(); if ($transport->getIsExtensionInstalled()) { $cart = $this->findExistingEntity($order->getCart()); $cartOriginId = $order->getCart()->getOriginId(); if (!$cart && $cartOriginId) { $this->appendDataToContext(ContextCartReader::CONTEXT_POST_PROCESS_CARTS, $cartOriginId); $isProcessingAllowed = false; } } if (!$customer && $order->getIsGuest() && $transport->getGuestCustomerSync()) { $this->appendDataToContext('postProcessGuestCustomers', $this->context->getValue('itemData')); $isProcessingAllowed = false; } return $isProcessingAllowed; }
/** * If cart exists then add relation to it, * do nothing otherwise * * @param Order $entity */ protected function processCart(Order $entity) { // cart could be array if comes new order or object if comes from DB $cartId = is_object($entity->getCart()) ? $entity->getCart()->getOriginId() : $entity->getCart()['originId']; $criteria = ['originId' => $cartId, 'channel' => $entity->getChannel()]; /** @var Cart|null $cart */ $cart = $this->getEntityByCriteria($criteria, MagentoConnectorInterface::CART_TYPE); if ($cart) { $statusClass = MagentoConnectorInterface::CART_STATUS_TYPE; $purchasedStatus = $this->strategyHelper->getEntityManager($statusClass)->find($statusClass, 'purchased'); if ($purchasedStatus) { $cart->setStatus($purchasedStatus); } } $entity->setCart($cart); }
/** * @param Order $order * @param Customer $customer */ protected function processCustomer(Order $order, Customer $customer = null) { if (!$customer || !$customer->getId()) { $customer = $this->databaseHelper->findOneBy('OroCRM\\Bundle\\MagentoBundle\\Entity\\Customer', ['email' => $order->getCustomerEmail(), 'channel' => $order->getChannel()]); } if ($customer instanceof Customer) { // now customer orders subtotal calculation support only one currency. // also we do not take into account order refunds due to magento does not bring subtotal data // customer currency needs on customer's grid to format lifetime value. $customer->setCurrency($order->getCurrency()); } $order->setCustomer($customer); if ($order->getCart()) { $order->getCart()->setCustomer($customer); } }
/** * @Route("/actualize/{id}", name="orocrm_magento_order_actualize", requirements={"id"="\d+"})) * @AclAncestor("orocrm_magento_order_view") * @param Order $order * @return \Symfony\Component\HttpFoundation\RedirectResponse */ public function actualizeAction(Order $order) { $result = false; try { $result = $this->loadOrderInformation($order->getChannel(), ['filters' => ['increment_id' => $order->getIncrementId()]]); } catch (\LogicException $e) { $this->get('logger')->addCritical($e->getMessage(), ['exception' => $e]); } if ($result === true) { $this->get('session')->getFlashBag()->add('success', $this->get('translator')->trans('orocrm.magento.controller.synchronization_success')); } else { $this->get('session')->getFlashBag()->add('error', $this->get('translator')->trans('orocrm.magento.controller.synchronization_error')); } return $this->redirect($this->generateUrl('orocrm_magento_order_view', ['id' => $order->getId()])); }
/** * @Route("/actualize/{id}", name="orocrm_magento_order_actualize", requirements={"id"="\d+"})) * @AclAncestor("orocrm_magento_order_view") */ public function actualizeAction(Order $order) { try { $processor = $this->get('oro_integration.sync.processor'); $processor->process($order->getChannel(), 'order', ['filters' => ['increment_id' => $order->getIncrementId()]]); $this->get('session')->getFlashBag()->add('success', $this->get('translator')->trans('orocrm.magento.controller.synchronization_success')); } catch (\LogicException $e) { $this->get('logger')->addCritical($e->getMessage(), ['exception' => $e]); $this->get('session')->getFlashBag()->add('error', $this->get('translator')->trans('orocrm.magento.controller.synchronization_error')); } return $this->redirect($this->generateUrl('orocrm_magento_order_view', ['id' => $order->getId()])); }