• Модуль: catalog
  • Путь к файлу: ~/bitrix/modules/catalog/lib/model/product.php
  • Класс: BitrixCatalogModelProduct
  • Вызов: Product::calculateAvailable
static function calculateAvailable(array &$fields, array &$actions)
{
	$result = null;

	switch ($fields['TYPE'])
	{
		case CatalogProductTable::TYPE_PRODUCT:
		case CatalogProductTable::TYPE_FREE_OFFER:
			$result = CatalogProductTable::calculateAvailable($fields);
			$actions[self::ACTION_RECALCULATE_SETS] = true;
			$actions[self::ACTION_SEND_NOTIFICATIONS] = true;
			break;
		case CatalogProductTable::TYPE_OFFER:
			$result = CatalogProductTable::calculateAvailable($fields);
			if (!self::$separateSkuMode)
				$actions[self::ACTION_CHANGE_PARENT_AVAILABLE] = true;
			$actions[self::ACTION_RECALCULATE_SETS] = true;
			$actions[self::ACTION_SEND_NOTIFICATIONS] = true;
			break;
		case CatalogProductTable::TYPE_SKU:
			if (self::$separateSkuMode)
				$result = CatalogProductTable::calculateAvailable($fields);
			else
				$actions[self::ACTION_CHANGE_PARENT_AVAILABLE] = true;
			break;
		case CatalogProductTable::TYPE_SET:
			$result = CatalogProductTable::calculateAvailable($fields);
			break;
		case CatalogProductTable::TYPE_EMPTY_SKU:
			$result = CatalogProductTable::STATUS_NO;
			break;
		case CatalogProductTable::TYPE_SERVICE:
			if (isset($fields['QUANTITY']))
			{
				$result = ($fields['QUANTITY'] > 0 ? CatalogProductTable::STATUS_YES : CatalogProductTable::STATUS_NO);
				$actions[self::ACTION_SEND_NOTIFICATIONS] = true;
			}
	}

	$fields['AVAILABLE'] = $result;
}