Answer the question
In order to leave comments, you need to log in
How to work with Bitrix CCatalogDiscount::GetList method correctly?
You need to get the values of discounts for goods on the main page in the sliders. In the product card sliders.
I found the CCatalogDiscount::GetList method in the documentation, I can’t figure out how to work with it correctly. It returns the fields I need: NAME - the name of the discount, VALUE - the amount of the discount, and others.
There is already a ready-made code through which the goods are received in the slider by the property:
<?
if(CModule::IncludeModule("iblock")){
$arSelect = Array(
"ID",
"IBLOCK_ID",
"DETAIL_PAGE_URL",
"NAME", "PREVIEW_PICTURE",
"PREVIEW_TEXT",
"DATE_ACTIVE_FROM",
"CATALOG_GROUP_1",
);
$arrFilterMain["PROPERTY_CATMAIN_PROD_VALUE"] = "выгодные комплекты";
$res = CIBlockElement::GetList(
Array(),
$arrFilterMain,
false,
Array("nPageSize"=>50),
$arSelect
);
while($ob = $res->GetNextElement()) {
$arFields = $ob->GetFields();
$arProps = $ob->GetProperties();
//debug($arProps);
}
}
<?
// Выберем все скидки для данного товара
$dbProductDiscounts = CCatalogDiscount::GetList(
array("SORT" => "ASC"),
array(
"+PRODUCT_ID" => 64,
"ACTIVE" => "Y",
"!>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")),
"COUPON" => ""
),
false,
false,
array(
"ID", "SITE_ID", "ACTIVE", "ACTIVE_FROM", "ACTIVE_TO",
"RENEWAL", "NAME", "SORT", "MAX_DISCOUNT", "VALUE_TYPE",
"VALUE", "CURRENCY", "PRODUCT_ID"
)
);
while ($arProductDiscounts = $dbProductDiscounts->Fetch())
{
print_r = $arProductDiscounts;
}
?>
[PRICES] => Array
(
[price_type] => Array
(
[PRICE_ID] => 1
[ID] => 13
[CAN_ACCESS] => Y
[CAN_BUY] => Y
[MIN_PRICE] => Y
[CURRENCY] => RUB
[VALUE_VAT] => 6900
[VALUE_NOVAT] => 6900
[DISCOUNT_VALUE_VAT] => 6865
[DISCOUNT_VALUE_NOVAT] => 6865
[ROUND_VALUE_VAT] => 6865
[ROUND_VALUE_NOVAT] => 6865
[VALUE] => 6900
[UNROUND_DISCOUNT_VALUE] => 6865
[DISCOUNT_VALUE] => 6865
[DISCOUNT_DIFF] => 35
[DISCOUNT_DIFF_PERCENT] => 1
[VATRATE_VALUE] => 0
[DISCOUNT_VATRATE_VALUE] => 0
[ROUND_VATRATE_VALUE] => 0
[PRINT_VALUE_NOVAT] => 6 900 руб.
[PRINT_VALUE_VAT] => 6 900 руб.
[PRINT_VATRATE_VALUE] => 0 руб.
[PRINT_DISCOUNT_VALUE_NOVAT] => 6 865 руб.
[PRINT_DISCOUNT_VALUE_VAT] => 6 865 руб.
[PRINT_DISCOUNT_VATRATE_VALUE] => 0 руб.
[PRINT_VALUE] => 6 900 руб.
[PRINT_DISCOUNT_VALUE] => 6 865 руб.
[PRINT_DISCOUNT_DIFF] => 35 руб.
)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question