D
D
Dmitry Zorin2021-06-16 15:21:24
1C-Bitrix
Dmitry Zorin, 2021-06-16 15:21:24

How to change the rule for displaying all product properties?

There is a code that displays all the properties of the product, if "display" is set

if (!empty($arResult['DISPLAY_PROPERTIES']))
                {
                  ?>
                  <dl class="product-item-detail-properties"
                    <?
                    foreach ($arResult['DISPLAY_PROPERTIES'] as $property)
                    {
                      ?>
                      <dt><?=$property['NAME']?></dt>
                      <dd><?=(
                        is_array($property['DISPLAY_VALUE'])
                          ? implode(' / ', $property['DISPLAY_VALUE'])
                          : $property['DISPLAY_VALUE']
                        )?>
                      </dd>
                      <?
                    }
                    unset($property);
                    ?>
                  </dl>
                  <?
                }

How to attach to this code the rule that if the PROPERTY of the product is ['SPOSOB_PRIMENENIYA'] - then it is not displayed.

The bottom line is, I screwed this property separately into the product card template, but how do I "cut" this property from the code that I inserted above. It just outputs everything

PS To display it elsewhere in the template, I added the following code
<? if ($arResult["DISPLAY_PROPERTIES"]['SPOSOB_PRIMENENIYA']){?>
<?=$arResult['DISPLAY_PROPERTIES']['SPOSOB_PRIMENENIYA']['NAME']?>
<?echo $arResult['DISPLAY_PROPERTIES']['SPOSOB_PRIMENENIYA']['DISPLAY_VALUE'];?>
<?}?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Edward, 2021-06-16
@xxoooo

One option, before foreach:

unset($arResult['DISPLAY_PROPERTIES']['SPOSOB_PRIMENENIYA']);

Or:
foreach ($arResult['DISPLAY_PROPERTIES'] as $key => $property)
{
  if ( $key == 'SPOSOB_PRIMENENIYA' ) {
    continue;
  }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question