I
I
itemashabanov2021-01-14 17:37:26
SQL
itemashabanov, 2021-01-14 17:37:26

Selecting infoblock element properties by Bitrix mask?

Hello. There is an infoblock, and it has properties of the UF_404_DESIGN type. So, when displaying the elements of this infoblock, in addition to the properties NAME, ID, etc., you need to display the properties by mask, i.e. UF_404_*. This property can be empty, but it must be displayed. I do this, the mask does not work. Tell me, please, how to do it right?

$arSelect = Array("ID", "IBLOCK_ID", "DETAIL_TEXT", "PROPERTY_UF_404_*");
$arFilter = Array("IBLOCK_ID" => $arParams["REVIEW_IBLOCK_ID"], "CODE" => !empty($arParams["USE_SKU"]) ? $arBaseProduct["ID"] : $arResult["ID"]);
$res      = CIBlockElement::GetList(Array("SORT" => "ASC", "CREATED_DATE"), $arFilter, false, false, $arSelect);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
PetrPo, 2021-01-14
@itemashabanov

$iblockId = $arParams["REVIEW_IBLOCK_ID"];
$properties = $elements = [];

$iterator = \Bitrix\Iblock\PropertyTable::getList([
  'select' => ['CODE'],
  'filter' => ['IBLOCK_ID' => $iblockId, 'ACTIVE' => 'Y'],
]);
while($row = $iterator->fetch()) {
  $propertyCode = $row['CODE'];
  
  if(strpos($propertyCode, 'UF_404_') !== false) {
    $properties[] = 'PROPERTY_'.$propertyCode;
  }
}

$arSelect = Array("ID", "IBLOCK_ID", "DETAIL_TEXT");
$arSelect = array_merge($arSelect, $properties);
$arFilter = Array("IBLOCK_ID" => $iblockId, "CODE" => !empty($arParams["USE_SKU"]) ? $arBaseProduct["ID"] : $arResult["ID"]);
$res      = CIBlockElement::GetList(Array("SORT" => "ASC", "CREATED_DATE"), $arFilter, false, false, $arSelect);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question