A
A
alexwprof2019-08-15 15:00:54
1C-Bitrix
alexwprof, 2019-08-15 15:00:54

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);
   }

I receive contents of PROPERTIES in an array. Everything would be fine. All data is displayed along with the fields. Maybe it's trite, but I can't pass the array to the template in the form in which I need it. If the array is passed, then with only one product. That is, it contains information from only one product. And I need everything to be there, this is necessary for sorting and substituting pictures for each category. And that turns out, under all categories the same property from one goods is substituted.
Does anyone know what happens in this case. I'm interested in the question. How to correctly pass an array to the template so that all products are available there, and not just one?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vyacheslav Shevchenko, 2019-08-15
@WebDev2030

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 question

Ask a Question

731 491 924 answers to any question