@api

@param array $orderItems
@param \Orm\Zed\Sales\Persistence\SpySalesOrder $orderEntity
@param \Spryker\Zed\Oms\Business\Util\ReadOnlyArrayObject $data

@return array
979698
public function run(array $orderItems, SpySalesOrder $orderEntity, ReadOnlyArrayObject $data)
    {
        $paymentEntity = $orderEntity->getSpyPaymentPayones()->getFirst();
        $this->getFacade()->preAuthorizePayment($paymentEntity->getFkSalesOrder());

        return [];
    }
741256
private function snapshotCursorValues(DocumentSnapshot $snapshot, array $orderBy)
    {
        $fieldValues = [];
        foreach ($orderBy as $order) {
            $path = $order['field']['fieldPath'];
            if ($path === self::DOCUMENT_ID) {
                continue;
            }

            $fieldValues[] = $snapshot->get($path);
        }

        $fieldValues[] = $snapshot->reference();
        return $fieldValues;
    }
774750
private function processOrderItems($orderData, $syncCustomOption)
    {
        foreach ($orderData->getAllItems() as $productItem) {
            //product custom options
            $customOptions = [];
            if ($syncCustomOption) {
                $customOptions = $this->_getOrderItemOptions($productItem);
            }

            $productModel = $productItem->getProduct();

            if ($productModel) {
                // category names
                $categoryCollection = $productModel->getCategoryCollection()
                    ->addAttributeToSelect('name');
                $productCat = [];
                foreach ($categoryCollection as $cat) {
                    $categories = [];
                    $categories[] = $cat->getName();
                    $productCat[]['Name'] = $this->limitLength(
                        implode(', ', $categories)
                    );
                }

                $attributes = [];
                //selected attributes from config
                $configAttributes = $this->helper->getWebsiteConfig(
                    \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_SYNC_ORDER_PRODUCT_ATTRIBUTES,
                    $orderData->getStore()->getWebsite()
                );

                if ($configAttributes) {
                    $configAttributes = explode(',', $configAttributes);
                    //attributes from attribute set
                    $attributesFromAttributeSet = $this->_getAttributesArray(
                        $productModel->getAttributeSetId()
                    );

                    $attributes = $this->processConfigAttributes(
                        $configAttributes,
                        $attributesFromAttributeSet,
                        $productModel,
                        $attributes
                    );
                }

                $attributeSetName = $this->getAttributeSetName($productModel);

                $productData = [
                    'name' => $productItem->getName(),
                    'sku' => $productItem->getSku(),
                    'qty' => (int)number_format(
                        $productItem->getData('qty_ordered'),
                        2
                    ),
                    'price' => (float)number_format(
                        $productItem->getPrice(),
                        2,
                        '.',
                        ''
                    ),
                    'attribute-set' => $attributeSetName,
                    'categories' => $productCat,
                    'attributes' => $attributes,
                    'custom-options' => $customOptions,
                ];
                if (!$customOptions) {
                    unset($productData['custom-options']);
                }
                $this->products[] = $productData;
            } else {
                // when no product information is available limit to this data
                $productData = [
                    'name' => $productItem->getName(),
                    'sku' => $productItem->getSku(),
                    'qty' => (int)number_format(
                        $productItem->getData('qty_ordered'),
                        2
                    ),
                    'price' => (float)number_format(
                        $productItem->getPrice(),
                        2,
                        '.',
                        ''
                    ),
                    'attribute-set' => '',
                    'categories' => [],
                    'attributes' => [],
                    'custom-options' => $customOptions,
                ];
                if (!$customOptions) {
                    unset($productData['custom-options']);
                }
                $this->products[] = $productData;
            }
        }
    }
432235
public function createFor(Order $order, array $data, array $filters = [])
    {
        return $this->createForId($order->id, $data, $filters);
    }
101824
public function prepareInvoiceWithoutItems(OrderInterface $order, $amount)
    {
        try {
            $invoice = $this->orderConverter->toInvoice($order);
            $invoice->setBaseGrandTotal($amount);
            $invoice->setSubtotal($amount);
            $invoice->setBaseSubtotal($amount);
            $invoice->setGrandTotal($amount);

            $order->getInvoiceCollection()->addItem($invoice);

            return $invoice;
        } catch(\Exception $e) {
            $this->bugsnag->notifyException($e);
            throw $e;
        }
    }
153705
public function check(SpySalesOrderItem $orderItem)
    {
        return $this->getFacade()
            ->isPaymentOverpaid($orderItem->getFkSalesOrder(), $orderItem->getIdSalesOrderItem());
    }
769728
private function sortByArray($items, array $order)
    {
        $unordered = [];
        foreach ($items as $content) {
            $unordered[$content->getId()] = $content;
        }

        $ordered = [];
        foreach ($order as $id) {
            if (isset($unordered[$id])) {
                $ordered[] = $unordered[$id];
            }
        }

        return $ordered;
    }
990178
public function check(SpySalesOrderItem $orderItem)
    {
        return $this->getFacade()
            ->isPaymentCapture($orderItem->getFkSalesOrder(), $orderItem->getIdSalesOrderItem());
    }
35438
public function check(SpySalesOrderItem $orderItem)
    {
        $order = $orderItem->getOrder();

        if (isset(self::$resultCache[$this->getName()][$order->getPrimaryKey()])) {
            return self::$resultCache[$this->getName()][$order->getPrimaryKey()];
        }

        $orderTransfer = new OrderTransfer();
        $orderTransfer->fromArray($order->toArray(), true);

        $isSuccess = $this->callFacade($orderTransfer);
        self::$resultCache[$order->getPrimaryKey()] = $isSuccess;

        return $isSuccess;
    }
1181234
public function check(SpySalesOrderItem $orderItem)
    {
        return $this->getFacade()
            ->isPaymentRefund($orderItem->getFkSalesOrder(), $orderItem->getIdSalesOrderItem());
    }
814473
public function getWeekViewForOrderCollection(OrderCollection $orderCollection)
    {
        $weekView = new WeekView(new \DateTime(), null, 'D d');

        $windows = $this->findForSelectWindowForOrderCollection($orderCollection, $weekView->getEndDate());

        foreach ($windows as $window)
        {
            $weekView->addObject($window);
        }

        return $weekView;
    }
1287187
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
    {
        $persister = $this->entityManager->getEntityPersister($this->className);

        return $persister->loadAll($criteria, $orderBy, $limit, $offset);
    }
1147383
public function findOneBy(array $criteria, array $orderBy = null)
    {
        $persister = $this->_em->getUnitOfWork()->getEntityPersister($this->_entityName);

        return $persister->load($criteria, null, null, array(), null, 1, $orderBy);
    }
199746
public function addItem(
        $itemData,
        $locale,
        $userId,
        OrderEntity $order,
        ItemInterface $lastProcessedProductItem = null
    ) {
        $item = $this->itemManager->save(
            $itemData,
            $locale,
            $userId,
            null,
            null,
            $order->getCustomerContact(),
            $lastProcessedProductItem
        );

        $order->addItem($item->getEntity());

        return $item;
    }
429767
protected function fromArray( \Aimeos\MShop\Order\Item\Base\Iface $order, array $data )
	{
		$invoiceIds = $this->getValue( $data, 'order.id', [] );
		$manager = \Aimeos\MShop::create( $this->getContext(), 'order' );

		$search = $manager->createSearch()->setSlice( 0, count( $invoiceIds ) );
		$search->setConditions( $search->compare( '==', 'order.id', $invoiceIds ) );

		$items = $manager->searchItems( $search );


		foreach( $invoiceIds as $idx => $id )
		{
			if( !isset( $items[$id] ) ) {
				$item = $manager->createItem();
			} else {
				$item = $items[$id];
			}

			if( isset( $data['order.statusdelivery'][$idx] ) ) {
				$item->setDeliveryStatus( $data['order.statusdelivery'][$idx] );
			}

			if( isset( $data['order.statuspayment'][$idx] ) ) {
				$item->setPaymentStatus( $data['order.statuspayment'][$idx] );
			}

			if( isset( $data['order.datedelivery'][$idx] ) ) {
				$item->setDateDelivery( $data['order.datedelivery'][$idx] );
			}

			if( isset( $data['order.datepayment'][$idx] ) ) {
				$item->setDatePayment( $data['order.datepayment'][$idx] );
			}

			if( isset( $data['order.relatedid'][$idx] ) ) {
				$item->setRelatedId( $data['order.relatedid'][$idx] );
			}

			if( isset( $data['order.type'][$idx] ) ) {
				$item->setType( $data['order.type'][$idx] );
			}

			$item->setBaseId( $order->getId() );

			$manager->saveItem( $item );
		}
	}
873688
public function updateItem($itemId, $data, $user = null, $locale = null)
    {
        $cart = $this->getUserCart($user, $locale);
        $userId = $user ? $user->getId() : null;

        $this->validateOrCreateAddresses($cart, $user);

        $item = $this->orderManager->getOrderItemById($itemId, $cart->getEntity());

        $this->orderManager->updateItem($item, $data, $locale, $userId);

        $this->removeOrderAddressIfContactAddressIdIsEqualTo(
            $item,
            $cart->getDeliveryAddress()->getContactAddress()->getId()
        );

        $this->orderManager->updateApiEntity($cart, $locale);

        return $cart;
    }
471881
public static function sort_terms( $terms, $orderby = 'term_id', $order = 'ASC' ) {

		if ( function_exists( 'wp_list_sort' ) ) {
			$terms = wp_list_sort( $terms, 'term_id', 'ASC' );
		} else {

			if ( 'name' === $orderby ) {
				usort( $terms, '_usort_terms_by_name' );
			} else {
				usort( $terms, '_usort_terms_by_ID' );
			}

			if ( 'DESC' === $order ) {
				$terms = array_reverse( $terms );
			}
		}

		return $terms;
	}