• Модуль: catalog
  • Путь к файлу: ~/bitrix/modules/catalog/lib/product/catalogprovider.php
  • Класс: BitrixCatalogProductCatalogProvider
  • Вызов: CatalogProvider::reserveQuantityWithDisabledReservation
static function reserveQuantityWithDisabledReservation(array $productData): SaleResult
	{
		$result = new SaleResult();

		$catalogData = $productData['CATALOG'];

		$isQuantityTrace = $catalogData["QUANTITY_TRACE"] == 'Y';

		$productQuantity = self::getTotalAmountFromQuantityList($productData);
		$catalogQuantity = self::getTotalAmountFromPriceList($catalogData);

		$isUpdated = true;

		$fields = array(
			'QUANTITY' => $catalogQuantity
		);

		if ($isQuantityTrace)
		{
			$productId = $productData['PRODUCT_ID'];
			$fields['QUANTITY'] -= $productQuantity;
			if ($catalogData["CAN_BUY_ZERO"] != "Y" && ($catalogQuantity < $productQuantity))
			{
				$result->addWarning(
					new SaleResultWarning(
						MainLocalizationLoc::getMessage(
							"RESERVE_QUANTITY_NOT_ENOUGH_ERROR",
							array_merge(
								self::getProductCatalogInfo($productId),
								array("#PRODUCT_ID#" => $productId)
							)
						), "RESERVE_QUANTITY_NOT_ENOUGH_ERROR"
					)
				);

				$fields['QUANTITY'] = 0;
			}

			$internalResult = CatalogModelProduct::update($productId, $fields);
			if (!$internalResult->isSuccess())
			{
				$isUpdated = false;
				self::convertErrors($internalResult);
			}
			unset($internalResult);
		}

		if ($isUpdated)
		{
			$result->setData($fields);
		}

		return $result;
	}