P
P
photosho2020-12-30 17:11:05
1C-Bitrix
photosho, 2020-12-30 17:11:05

How to automatically get the value of the File property?

Is it possible in Bitrix to automatically process all the properties of an element, regardless of their type (we don’t even consider complex types, for example, lists)? Integers, strings and files.

$props = $item->getProperties();

foreach ($props as $key => $prop)
    $result[$key] = $prop['VALUE'];

That is, you need a one-dimensional array [Key => Value], but with this approach, properties of the "File" type store not the path to the file, but its ID.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
photosho, 2020-12-31
@photosho

You can automatically process properties depending on the type:

$props = $item->getProperties();

foreach ($props as $key => $prop) {
    if ($prop['PROPERTY_TYPE'] == 'F')
        $result[$key] = CFile::getPath($prop['VALUE']);

    else $result[$key] = $prop['VALUE'];
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question