Answer the question
In order to leave comments, you need to log in
How to get a list of catalog products by ID, with data on prices and discounts?
The task is to get a list of products with the given properties: Hit, Promotion, New, etc.
I use the method: CIBlockElement::GetList - with a selection by the "PROPERTY_STICKERS_VALUE" property. This is how I get data to display a list of goods, but I can’t imagine how to get data with prices with a discount, without a discount, and the size of the discount.
The GetList method allows you to get the base price of the product, but the base prices are set in Euros, and you need to display the price of the product on the site converted in rubles, with a discount and an indication of its size.
How to get a group of catalog products by ID with data on prices converted in rubles, prices with a discount and its size?
Answer the question
In order to leave comments, you need to log in
Problem solved. I will describe the solution, maybe it will be useful to someone.
Initially, it was necessary to display a block with catalog products on the main page of the catalog, according to the PROPERTY_STICKERS property - a list type, which are set to Hit, Recommended, New, Promotions to display products with the corresponding stickers. In this case, the goods should be displayed with the size of discounts, indicating the old price, the price converted from the currency into rubles.
Bitrix methods CIBlockElement::GetList and CCatalogDiscount::GetList are not ideal for solving this problem. In my opinion, it is more appropriate to use the catalog.section component with a property filter. Why the filter is set in the component parameters:
"USE_FILTER" => "Y",
"FILTER_NAME" => "arrFilterAdvice",
<? $GLOBALS['arrFilterAdvice'] = array('ACTIVE' => 'Y', '!PROPERTY_STICKERS' => false);
$APPLICATION->IncludeComponent(
"bitrix:catalog.section",
"shop_window",
array(
…
"USE_FILTER" => "Y",
"FILTER_NAME" => "arrFilterAdvice",
…
if(!$arResult["ADVICE"]){
foreach($arResult["ITEMS"] as $Element){
foreach($Element["PROPERTIES"]["STICKERS"]["VALUE_XML_ID"] as $type){
if($type == "HIT") $arResult["ADVICE"]["HIT"][$Element["ID"]] = $Element;
if($type == "RECOMMEND") $arResult["ADVICE"]["RECOMMEND"][$Element["ID"]] = $Element;
if($type == "NEW") $arResult["ADVICE"]["NEW"][$Element["ID"]] = $Element;
if($type == "STOCK") $arResult["ADVICE"]["STOCK"][$Element["ID"]] = $Element;
}
}
}
Use CCatalogDiscount::GetList and concatenate the resulting array of IDs, removing values that are not in your CIBlockElement::GetList selection - with the selection by the "PROPERTY_STICKERS_VALUE" property.
$dbProductDiscounts = CCatalogDiscount::GetList(
array("SORT" => "ASC"),
array("ACTIVE" => "Y"),
false,
false,
array("ID", "PRODUCT_ID")
);
while ($arProductDiscounts = $dbProductDiscounts->Fetch()) {
$akcii_arr[] = $arProductDiscounts["PRODUCT_ID"];
}
foreach($akcii_arr as $ID) {
$akcii_arr_[] = $ID;
}
$GLOBALS['arrFilterAkcii'] = array("ID"=>$akcii_arr_);
?>
<?$APPLICATION->IncludeComponent("bitrix:catalog.top", "", Array(
"FILTER_NAME" => "arrFilterAkcii", // Имя массива со значениями фильтра для фильтрации элементов
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question