<?php
$dbProductDiscounts = CCatalogDiscount::GetList(
array("SORT" => "ASC"),
array(
"SITE_ID" => SITE_ID,
"ACTIVE" => "Y",
"!>ACTIVE_FROM" => $DB->FormatDate(date("Y-m-d H:i:s"),
"YYYY-MM-DD HH:MI:SS",
CSite::GetDateFormat("FULL")),
$DB->FormatDate(date("Y-m-d H:i:s"),
"YYYY-MM-DD HH:MI:SS",
CSite::GetDateFormat("FULL")),
"!<ACTIVE_TO" => $DB->FormatDate(date("Y-m-d H:i:s"),
"YYYY-MM-DD HH:MI:SS",
CSite::GetDateFormat("FULL")),
$DB->FormatDate(date("Y-m-d H:i:s"),
"YYYY-MM-DD HH:MI:SS",
CSite::GetDateFormat("FULL")),
),
false,
false,
array(
"ID", "CONDITIONS"
)
);
while ($arProductDiscounts = $dbProductDiscounts->Fetch()) {
}
?>
$discountIds = [];
$discountIterator = Bitrix\Sale\Internals\DiscountTable::getList([
'select' => ["ID", "ACTIVE_FROM", "ACTIVE_TO", "CONDITIONS_LIST", "ACTIONS_LIST"],
'filter' => ['ACTIVE' => 'Y', "USE_COUPONS"=>"N", "DISCOUNT_TYPE"=>"P", [
"LOGIC" => "OR",
[
"<=ACTIVE_FROM"=>$DB->FormatDate(date("Y-m-d H:i:s"),"YYYY-MM-DD HH:MI:SS",\CSite::GetDateFormat("FULL")),
">=ACTIVE_TO"=>$DB->FormatDate(date("Y-m-d H:i:s"),"YYYY-MM-DD HH:MI:SS",\CSite::GetDateFormat("FULL"))
],
[
"=ACTIVE_FROM"=>false,
">=ACTIVE_TO"=>$DB->FormatDate(date("Y-m-d H:i:s"),"YYYY-MM-DD HH:MI:SS",\CSite::GetDateFormat("FULL"))
],
[
"<=ACTIVE_FROM"=>$DB->FormatDate(date("Y-m-d H:i:s"),"YYYY-MM-DD HH:MI:SS",\CSite::GetDateFormat("FULL")),
"=ACTIVE_TO"=>false
],
[
"=ACTIVE_FROM"=>false,
"=ACTIVE_TO"=>false
],
]],
]);
while ($discount = $discountIterator->fetch()) {
$discountIds[$discount['ID']] = $discount;
$discountProducts[] = $discount["CONDITIONS_LIST"]["CHILDREN"][0]["CHILDREN"][0]["DATA"]["value"][0];
}