• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/Service/Sale/Shipment/ProductService.php
  • Класс: Bitrix\Crm\Service\Sale\Shipment\ProductService
  • Вызов: ProductService::getShippedQuantityByRowBasketMap
public function getShippedQuantityByRowBasketMap(array $productRow2basket, bool $onlyDeducted = true): array
{
	$result = [];

	$filter = [
		'=BASKET_ID' => array_values($productRow2basket),
	];
	if ($onlyDeducted)
	{
		$filter['=DELIVERY.DEDUCTED'] = 'Y';
	}

	$rows = ShipmentItemTable::getList([
		'select' => [
			'BASKET_ID',
			'SUM_QUANTITY',
		],
		'filter' => $filter,
		'runtime' => [
			new ExpressionField('SUM_QUANTITY', 'SUM(%s)', 'QUANTITY'),
		],
		'group' => [
			'BASKET_ID',
		],
	]);
	$basketIdToQuantity = array_column($rows->fetchAll(), 'SUM_QUANTITY', 'BASKET_ID');

	foreach ($productRow2basket as $rowId => $basketId)
	{
		$result[$rowId] = (float)($basketIdToQuantity[$basketId] ?? 0.0);
	}
	return $result;
}