Vinoteca: wine shop on 1C-Bitrix (module, template, components, pages)

This commit is contained in:
jimagie committed 2026-10-22 19:35:23 +05:00
commit 0590195880
593 files changed
+27942

No files matched your search

@@ -0,0 +1,38 @@
<?php
declare(strict_types=1);
namespace Jinove\Vinoteca;
use Bitrix\Iblock\ElementTable;
use Bitrix\Iblock\IblockTable;
use Bitrix\Main\Loader;
use Bitrix\Main\Type\DateTime;
final class Retention
{
private const QUESTIONS_CODE = "sommelier_questions";
private const MONTHS = 12;
private const BATCH = 200;
public static function purge(): string
{
if (Loader::includeModule("iblock")) {
$iblock = IblockTable::getRow(["select" => ["ID"], "filter" => ["=CODE" => self::QUESTIONS_CODE]]);
if ($iblock !== null) {
$before = new DateTime();
$before->add("-" . self::MONTHS . " months");
$rows = ElementTable::getList([
"select" => ["ID"],
"filter" => ["=IBLOCK_ID" => (int)$iblock["ID"], "<DATE_CREATE" => $before],
"limit" => self::BATCH,
]);
while ($row = $rows->fetch()) {
\CIBlockElement::Delete((int)$row["ID"]);
}
}
}
return __METHOD__ . "();";
}
}