D
D
Dmitry Grabko2020-10-01 17:54:10
1C-Bitrix
Dmitry Grabko, 2020-10-01 17:54:10

How to get a list type value when updating an element?

When updating an element by its property, you need to add a section binding to it. I can't figure out how exactly to get the value of type "list"

AddEventHandler("iblock", "OnAfterIBlockElementUpdate",'AddSeoSection');
function AddSeoSection(&$arFields)
{
  if ($arFields['PROPERTY_VALUES']['VALUE'] == 'настенный') { //пробую так
    $db_old_groups = CIBlockElement::GetElementGroups($arFields['ID'], true);
    $ar_new_groups = Array($NEW_GROUP_ID);
    while($ar_group = $db_old_groups->Fetch())
        $ar_new_groups[] = $ar_group["ID"];
        array_push($ar_new_groups, '807');
        CIBlockElement::SetElementSection($arFields['ID'], $ar_new_groups);
  }
}


Tried both by value ID and by $arFields['PROPERTY_TIP_USTANOVKI_VALUE'] - didn't help

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Grabko, 2020-10-01
@Dima_So

I did as suggested in the comments.

$db_props = CIBlockElement::GetProperty(32, $arFields['ID'], array("sort" => "asc"), Array("CODE"=>"TIP_USTANOVKI"));
  	if($ar_props = $db_props->Fetch())
  		$prop_val = $ar_props['VALUE'];
if($prop_val == 115419){...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question