Vinoteca: модуль, шаблон и компоненты интернет-магазина вина на 1С-Битрикс

This commit is contained in:
jimagie committed 2026-10-22 19:28:52 +05:00
commit bb7d8af290
469 files changed
+26426

No files matched your search

@@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
namespace Jinove\Vinoteca\Catalog;
use Bitrix\Main\Engine\CurrentUser;
use Bitrix\Main\Loader;
final class Prices
{
public static function optimal(array $productIds, string $siteId = SITE_ID): array
{
$productIds = array_values(array_unique(array_filter(array_map("intval", $productIds))));
if (!$productIds || !Loader::includeModule("catalog") || !Loader::includeModule("currency")) {
return [];
}
$groups = CurrentUser::get()->getUserGroups();
$prices = [];
foreach ($productIds as $productId) {
$optimal = \CCatalogProduct::GetOptimalPrice($productId, 1, $groups, "N", [], $siteId);
$price = $optimal["RESULT_PRICE"] ?? null;
if (!$price || (float)$price["DISCOUNT_PRICE"] <= 0) {
continue;
}
$prices[$productId] = [
"price" => (float)$price["DISCOUNT_PRICE"],
"base" => max((float)$price["DISCOUNT_PRICE"], (float)$price["BASE_PRICE"]),
"currency" => (string)$price["CURRENCY"],
];
}
return $prices;
}
}