• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/services/base/productcategoryrestriction.php
  • Класс: BitrixSaleServicesBaseProductCategoryRestriction
  • Вызов: ProductCategoryRestriction::check
static function check($categoriesList, array $restrictionParams, $deliveryId = 0) : bool
{
	if (
		empty($categoriesList)
		|| !is_array($categoriesList)
		|| empty($restrictionParams["CATEGORIES"])
		|| !is_array($restrictionParams["CATEGORIES"])
	)
	{
		return true;
	}

	foreach ($categoriesList as $productId => $productCategories)
	{
		if (!is_array($productCategories) || empty($productCategories))
		{
			continue;
		}

		$isProductFromCategory = false;

		foreach ($productCategories as $categoryId)
		{
			$categoryPath = self::getCategoriesPath($categoryId);

			if (array_intersect($categoryPath, $restrictionParams["CATEGORIES"]))
			{
				$isProductFromCategory =  true;
				break;
			}
		}

		if (!$isProductFromCategory)
		{
			return false;
		}
	}

	return true;
}