self::collect($iblockId, $sectionCode, $priceCode)); } public static function groupId(string $priceCode): int { if (!Loader::includeModule("catalog")) { return 0; } $group = GroupTable::getRow([ "select" => ["ID"], "filter" => ["=NAME" => $priceCode], "cache" => ["ttl" => self::CACHE_TTL], ]); return $group === null ? 0 : (int)$group["ID"]; } private static function collect(int $iblockId, string $sectionCode, string $priceCode): array { if (!Loader::includeModule("iblock")) { return []; } $groupId = self::groupId($priceCode); if ($groupId === 0) { return []; } $filter = [ "IBLOCK_ID" => $iblockId, "ACTIVE" => "Y", "SECTION_CODE" => $sectionCode, "INCLUDE_SUBSECTIONS" => "Y", ]; $total = (int)\CIBlockElement::GetList([], $filter, []); $limits = []; $previous = 0; foreach (self::LIMITS as $limit) { $count = (int)\CIBlockElement::GetList([], $filter + ["<=CATALOG_PRICE_" . $groupId => $limit], []); if ($count > $previous && $count < $total) { $limits[] = $limit; $previous = $count; } } return $limits; } }