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

	$productOrderList = CatalogProductCatalogProvider::createOrderListFromProducts($products);
	foreach ($products as $productId => $productData)
	{
		if (empty($productOrderList[$productId]))
		{
			continue;
		}

		/** @var SaleOrder $order */
		foreach ($productOrderList[$productId] as $order)
		{
			$resultList[$productId] = false;
			if (!empty($productData['SHIPMENT_ITEM_LIST']))
			{

				$quantityList = array();

				if (isset($productData['QUANTITY_LIST']))
				{
					$quantityList = $productData['QUANTITY_LIST'];
				}
				/**
				 * @var $shipmentIndex
				 * @var SaleShipmentItem $shipmentItem
				 */
				foreach ($productData['SHIPMENT_ITEM_LIST'] as $shipmentIndex => $shipmentItem)
				{

					/** @var SaleShipmentItemCollection $shipmentItemCollection */
					$shipmentItemCollection = $shipmentItem->getCollection();
					if (!$shipmentItemCollection)
					{
						throw new MainObjectNotFoundException('Entity "ShipmentItemCollection" not found');
					}

					$shipment = $shipmentItemCollection->getShipment();

					$basketItem = $shipmentItem->getBasketItem();

					$basketCode = $basketItem->getBasketCode();
					$quantity = null;

					if (isset($quantityList[$basketCode]))
					{
						$quantity = $quantityList[$basketCode];
					}

					$fields = array(
						"PRODUCT_ID" => $productId,
						"USER_ID"    => $order->getUserId(),
						"PAID"		 => $order->isPaid() ? 'Y' : 'N',
						"ORDER_ID"   => $order->getId(),

						"BASKET_CODE"   => $basketCode,
						"CALLBACK_FUNC"   => $basketItem->getField('CALLBACK_FUNC'),
						"MODULE"   => $basketItem->getField('MODULE'),
						"ALLOW_DELIVERY"   => $shipment->getField('ALLOW_DELIVERY'),
						"QUANTITY"   => $quantity,
					);

					$r = SaleProvider::deliverProductData($this->getProviderClass(), $fields);
					if ($r->isSuccess())
					{
						$resultData = $r->getData();

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

		}

	}


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

	return $result;
}