@param array $itemData
@param string $locale
@param int $userId
@param OrderEntity $order
@param ItemInterface|null $lastProcessedProductItem

@return ApiItemInterface
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;
    }
1309296
protected function _createItem( MShop_Price_Item_Interface $price, MShop_Locale_Item_Interface $locale,
		array $values = array(), array $products = array(), array $addresses = array(),
		array $services = array(), array $coupons = array() )
	{
		return new MShop_Order_Item_Base_Default( $price, $locale,
			$values, $products, $addresses, $services, $coupons );
	}
1171408
public function findAllByLocale($locale, $filter = array())
    {
        if (empty($filter)) {
            $order = $this->orderRepository->findAllByLocale($locale);
        } else {
            $order = $this->orderRepository->findByLocaleAndFilter($locale, $filter);
        }

        if ($order) {
            array_walk(
                $order,
                function (&$order) use ($locale) {
                    $order = $this->orderFactory->createApiEntity($order, $locale);
                    $this->updateApiEntity($order, $locale);
                }
            );
        }

        return $order;
    }
333028
public static function getStaticItem( int $item_id, string $locale = 'en_US', string $version = null ) : array
	{
		$data = self::getStaticItems($locale, $version);
		if (isset($data['data'][$item_id]) == false)
			throw new ArgumentException('Item with given ID was not found.', 404);

		return $data['data'][$item_id];
	}
644693
public function findFiltersForUserAndContext($context, $userId, $locale)
    {
        $filters = $this->filterRepository->findByUserAndContextAndLocale($locale, $context, $userId);
        array_walk(
            $filters,
            function(&$filter) use ($locale) {
                $filter = new Filter($filter, $locale);
            }
        );

        return $filters;
    }
1256805
private function findCartsByUser($user, $locale)
    {
        $cartsArray = $this->orderRepository->findByStatusIdsAndUser(
            $locale,
            array(OrderStatus::STATUS_IN_CART, OrderStatus::STATUS_CART_PENDING),
            $user
        );

        return $cartsArray;
    }
1050943
public function getDocuments($orderId, $locale)
    {
        $documents = array();
        /** @var SalesDependencyClassInterface $dependency */
        foreach ($this->dependencyClasses as $dependency) {
            // add to documents array
            $documents = array_merge($documents, $dependency->getDocuments($orderId, $locale));
        }

        return $documents;
    }
214316
public function getItem($itemId, $data = null)
	{
		$params = $this->setUpParams('item', $itemId, $data, 'itemListData', 'itemData');
		$array  = $this->makeRequest('item', $itemId, $params);

		if ($this->appendId($itemId))
		{
			return new staticItem($array);
		}
		else
		{
			return new ItemList($array);
		}
	}
692228
public function widgetToValue($varValue, $itemId)
    {
        if (null === $varValue) {
            return null;
        }
        static $cache = [];
        $attributeId = $this->get('id');
        if (array_key_exists($attributeId, $cache) && array_key_exists($varValue, $cache[$attributeId])) {
            return $cache[$attributeId][$varValue];
        }

        $model = $this->getSelectMetaModel();
        $alias = $this->getIdColumn();

        if ($model->hasAttribute($alias)) {
            $attribute = $model->getAttribute($alias);
            // It is an attribute, we may search for it.
            $ids = $attribute->searchFor($varValue);
        } else {
            // Must be a system column then.
            $result = $this->connection->createQueryBuilder()
                ->select('v.id')
                ->from($this->getSelectSource(), 'v')
                ->where('v.' . $this->getIdColumn() . '=:value')
                ->setParameter('value', $varValue)
                ->execute();

            $ids = $result->fetchAll(\PDO::FETCH_COLUMN);
        }

        // Maybe deleted value?
        if ([] === $ids) {
            return $cache[$attributeId][$varValue] = null;
        }

        // Multiple results.
        if (null === $ids || \count($ids) > 1) {
            throw new \RuntimeException(
                \sprintf(
                    'Multiple values found for %s, are there obsolete values for %s.%s (att_id: %s)?',
                    \var_export($varValue, true),
                    $model->getTableName(),
                    $this->getColName(),
                    $this->get('id')
                )
            );
        }
        $valueId = \array_shift($ids);

        $value = $this->getValuesById(
            [$valueId],
            [$this->getAliasColumn(), $this->getValueColumn(), $this->getIdColumn(), $this->getSortingColumn()]
        );

        return $cache[$attributeId][$varValue] = $value[$valueId];
    }
423648
protected function setUpParams($name = '', $requestId = null, $data = null, $listData = '', $itemData = '')
	{
		$params = [];
		if ( ! is_null($this->locale))
		{
			$params['locale'] = $this->locale;
		}
		if ( ! is_null($this->DDversion))
		{
			$params['version'] = $this->DDversion;
		}
		if ( ! $this->appendId($requestId) && $this->dataById($name))
		{
			$params['dataById'] = 'true';
		}
		if ( ! is_null($data))
		{
			if ($this->appendId($requestId))
			{
				if (is_array($data) && ! empty($data))
				{
					$data = implode(",", $data);
				}

				$params[$itemData] = $data;
			}
			else
			{
				if (is_array($data) && ! empty($data))
				{
					$data = implode(",", $data);
				}

				$params[$listData] = $data;
			}
		}

		return $params;
	}
794243
public function storeItemVariables($deliveryResultIdentifier, $test, $item, array $itemVariables, $callIdItem)
    {
        $variables = [];

        foreach ($itemVariables as $itemVariable) {
            $variables[] = $this->handleFiles($deliveryResultIdentifier, $itemVariable);
        }

        $this->getDbStorage()->storeItemVariables(
            $deliveryResultIdentifier,
            $test,
            $item,
            $variables,
            $callIdItem
        );
    }
751593
protected function setItemByProductData($productData, ApiItemInterface $item, $locale)
    {
        $productId = $this->getProductId($productData);

        /** @var Product $product */
        $product = $this->productRepository->find($productId);
        if (!$product) {
            throw new ProductNotFoundException(self::$productEntityName, $productId);
        }
        $item->setProduct($product);
        $translation = $product->getTranslation($locale);

        // when the product is not available in the current language choose the first translation you find
        // FIXME: should be changed when products have a language fallback
        // https://github.com/massiveart/POOL-ALPIN/issues/611
        if (is_null($translation)) {
            if (count($product->getTranslations()) > 0) {
                $translation = $product->getTranslations()[0];
            } else {
                throw new ProductException('Product ' . $product->getId() . ' has no translations!');
            }
        }

        $this->setItemSupplier($item, $product);

        $item->setName($translation->getName());
        $item->setDescription($translation->getLongDescription());
        $item->setNumber($product->getNumber());

        // set order unit
        if ($product->getOrderUnit()) {
            $item->setQuantityUnit($product->getOrderUnit()->getTranslation($locale)->getName());
        }

        // TODO: get tax from product https://github.com/massiveart/POOL-ALPIN/issues/1224
        $item->setTax(0);

        return $product;
    }
37860
public function addProduct($data, $user = null, $locale = null)
    {
        //TODO: locale
        // get cart
        $cart = $this->getUserCart($user, $locale, null, true);
        // define user-id
        $userId = $user ? $user->getId() : null;

        $item = $this->orderManager->addItem($data, $locale, $userId, $cart);

        $this->validateIfItemProductActive($item->getEntity());

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

        return $cart;
    }
879187
public function findByIdAndLocale($id, $locale)
    {
        $shipping = $this->getShippingRepository()->findByIdAndLocale($id, $locale);

        if ($shipping) {
            $apiShippings = $this->shippingFactory->createApiEntity($shipping, $locale);

            // set currently shipped items (sum of all shippings for that item)
            $shippingCounts = $this->getSumOfShippedItemsByOrderId($shipping->getOrder()->getId());
            foreach ($apiShippings->getItems() as $apiItem) {
                $itemId = $apiItem->getEntity()->getItem()->getId();
                $sum = 0;
                if (array_key_exists($itemId, $shippingCounts)) {
                    $sum = $shippingCounts[$itemId];
                }
                $apiItem->setShippedItems($sum);
            }
            return $apiShippings;
        } else {
            return null;
        }
    }
1149304
protected function createMediaForSupplierItems($items, $locale)
    {
        foreach ($items as $item) {
            if (isset($item['items']) && count($item['items'] > 0)) {
                $this->createMediaForItems($item['items'], $locale);
            }
        }
    }
689632
function(items, userData) {

		var selfHostingConfig = this._siteClient.getSelfHostingConfig();

		var self = this;
		var dialog = new ConvertToSelfHostingDialog({
			serviceRegistry: this.serviceRegistry,
			fileClient: this.fileClient,
			siteClient: this._siteClient,
			selfHostingConfig: selfHostingConfig,
			func: function(folderInfos) {
				var folderLocations = folderInfos.map(function(folderInfo) {
					return folderInfo.folder.Location;
				});
				self._siteClient.convertToSelfHosting(self.getSiteConfiguration(), folderLocations).then(
					function(updatedSite) {
						self.mappings.deleteAllMappings();
						self.mappings.addMappings(updatedSite.Mappings);
						self.save();
					});
			}
		});
		dialog.show();
	}
282898
private function getOrderItemVariables($item, $itemId)
    {
        $variables = [];

        if (!$item->isDummy()) {
            $prefix = "order.items.$itemId";
            $variables[$prefix . '.sku']        = $item->getSku();
            $variables[$prefix . '.product_id'] = $item->getProductId();
            $variables[$prefix . '.qty']        = $item->getQtyOrdered();
            $variables[$prefix . '.price']      = $item->getBasePrice();
            $variables[$prefix . '.row_total']  = $item->getRowTotal();
            $variables[$prefix . '.label']      = $item->getName();
            $variables[$prefix . '.salesrules'] = $item->getAppliedRuleIds();

            $product = $item->getProduct();
            if ($product) {
                $categoriesId = $product->getCategoryIds();
                if (count($categoriesId)) {
                    $variables[$prefix . '.category_ids'] = implode(",", $categoriesId);
                }
            }
        }

        return $variables;
    }