• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/internals/transferprovidercompatibility.php
  • Класс: BitrixSaleInternalsTransferProviderCompatibility
  • Вызов: TransferProviderCompatibility::recurring
public function recurring(array $products)
{
	global $USER;
	MainLoader::includeModule('catalog');

	$result = new SaleResult();
	$resultList = array();

	$productOrderList = CatalogProductCatalogProvider::createOrderListFromProducts($products);
	foreach ($products as $productId => $productData)
	{
		$productParamsList = array();
		if (!empty($productOrderList[$productId]))
		{
			/** @var SaleOrder $order */
			foreach ($productOrderList[$productId] as $order)
			{
				$hash = $order->getUserId();

				if (!isset($productParamsList[$hash]))
				{
					$productParamsList[$hash] = array(
						'PRODUCT_ID' => $productId,
						'USER_ID' => $order->getUserId(),
					);
				}

			}
		}
		else
		{
			$hash = $USER->getId();
			if (!isset($productParamsList[$hash]))
			{
				$productParamsList[$hash] = array(
					'PRODUCT_ID' => $productId,
					'USER_ID' => $USER->getId(),
				);
			}
		}

		foreach ($productParamsList as $productParams)
		{
			$r = SaleProvider::recurringProduct($this->getProviderClass(), $productParams);
			if ($r->isSuccess())
			{
				$resultData = $r->getData();

				if (array_key_exists($productId, $resultData))
				{
					$resultList[$productId] = $resultData[$productId];
				}
			}
		}

	}


	if (!empty($resultList))
	{
		$result->setData(
			array(
				'RECURRING_PRODUCTS_LIST' => $resultList
			)
		);
	}

	return $result;
}