/** * @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); }
/** * If cart exists then add relation to it, * do nothing otherwise * * @param Order $entity */ protected function processCart(Order $entity) { $cart = $entity->getCart(); if ($cart) { $statusClass = MagentoConnectorInterface::CART_STATUS_TYPE; /** @var CartStatus $purchasedStatus */ $purchasedStatus = $this->databaseHelper->findOneBy($statusClass, ['name' => CartStatus::STATUS_PURCHASED]); if ($purchasedStatus) { $cart->setStatus($purchasedStatus); } } $entity->setCart($cart); }