D
D
Darklt2020-12-10 22:27:04
1C-Bitrix
Darklt, 2020-12-10 22:27:04

How to load the parameter created in the Bitrix template into the infoblock?

There is a multiple infoblock row property with rating values, I display the average value in the template.

<?php $ratingVals = $arItem["PROPERTIES"]["rating"]["VALUE"];
$count = count($ratingVals);
$median = round (array_sum($ratingVals) / $count, 2); ?>
<?=$median?>

Where $arItem["PROPERTIES"]["rating"]["VALUE"] is the plural value 3,4,6 etc.
And <?=$median?> displays the average, how to enter this parameter into the infoblock?
In IB, a property is created, for example, "vote_sum"

I tried to create a certain structure in the file, but nothing comes out.

CModule::IncludeModule('iblock');
   
   $IBLOCK_ID = 48;
       $getProperty = CIBlockElement::GetList (
         Array("ID" => "ASC"),
         Array("IBLOCK_ID" => $IBLOCK_ID, "ID" => $arFields['ID']),
        false,
        false,
        Array(
           'Property_median'
         )
    );
    while($ar_fields = $getProperty->GetNext())
    {
         $setProperty= $ar_fields['vote_sum'];
    }

CIBlockElement::SetPropertyValuesEx (
      $arFields['ID'],$arFields['IBLOCK_ID'],array (
             'vote_sum' => $setProperty
          )
     );

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question