• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/Reservation/Component/InventoryManagementChecker.php
  • Класс: Bitrix\Crm\Reservation\Component\InventoryManagementChecker
  • Вызов: InventoryManagementChecker::checkAvailabilityServices
static function checkAvailabilityServices(array $products): Main\Result
{
	$result = new Main\Result();

	$productIds = array_column($products, 'PRODUCT_ID');
	if (!$productIds)
	{
		return $result;
	}

	$productIterator = Catalog\ProductTable::getList([
		'select' => [
			'ID',
			'AVAILABLE',
		],
		'filter' => [
			'=ID' => $productIds,
		],
	]);
	while ($product = $productIterator->fetch())
	{
		if ($product['AVAILABLE'] === Catalog\ProductTable::STATUS_NO)
		{
			$result->addError(
				new Main\Error("Product with id {$product['ID']} is not available")
			);
		}
	}

	return $result;
}