Answer the question
In order to leave comments, you need to log in
How to display product properties in the Bitrix menu?
There is a menu for Bitrix, we have to refine it. The principle of the menu is as follows, when you move the mouse to the link of a category, 4 pictures of its product appear on the right. It used to be easy, because the pictures were taken from the category itself. And now you need from the goods. I upload pictures from the MORE_PHOTO property. There is code in result_modifier.php:
if(CModule::IncludeModule("iblock"))
{
$arSelect = Array("ID", "IBLOCK_ID", "NAME", "DATE_ACTIVE_FROM","PROPERTY_*");
$arFilter = Array("IBLOCK_ID"=>2, "ACTIVE_DATE"=>"Y", "ACTIVE"=>"Y");
$res = CIBlockElement::GetList(Array(), $arFilter, false, Array("nPageSize"=>50), $arSelect);
while($ob = $res->GetNextElement()){
$arItem = $ob->GetFields();
$arItem["PROPERTIES"] = $ob->GetProperties();
$arResult[] = $arItem;
}
debug($arResult);
}
Answer the question
In order to leave comments, you need to log in
All of the above is not very clear.
As I understand it, the task is to make sure that each category has information about the first 4 products.
Well, then it's better to use the bitrix:catalog.section component and make a request for 4 products per category in the result_modifier.
$arSelect = Array("ID", "IBLOCK_ID", "NAME", "DATE_ACTIVE_FROM","PROPERTY_*");
$arFilter = Array("IBLOCK_ID"=>2, "ACTIVE_DATE"=>"Y", "ACTIVE"=>"Y");
foreach($arResult["SRCTIONS"] as ?$arSection) //Пробегаем по секциям
{
$arFilter["IBLOCK_SECTION_ID "] = $arSection["ID"]; //Добавляем в фильтр раздел товара
$res = CIBlockElement::GetList(Array(), $arFilter, false, Array("nPageSize"=>4), $arSelect); //получаем первые 4 товара
while($ob = $res->GetNextElement()){
$arItem = $ob->GetFields();
$arItem["PROPERTIES"] = $ob->GetProperties();
// Тут тебе нужны будут еще картинки так что код получения картинок сюда добавь
$arSection["ITEMS"] = $arItem;
}
}
//Код писал прям тут поэтому что-то может не работать :)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question