M
M
Maria Popova2018-06-04 16:01:22
1C-Bitrix
Maria Popova, 2018-06-04 16:01:22

How to update multiple file type field when?

I update the elements with the code using CIBlockElement::Update
The multiple property of the file type adds more photos, but it is necessary that the previous ones be deleted and new ones added. What needs to be done for this? (no need to delete the file)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita, 2018-06-04
@masha_0212

Something like this:

$rsProp = CIBlockElement::GetProperty($IBLOCK_ID, $ELEMENT_ID, array('sort' => 'asc'), array('CODE' => 'FILES'));
while($arProp = $rsProp->Fetch())
  $PROPERTY_VALUE[$arProp['PROPERTY_VALUE_ID']] = array('VALUE' => array('del'=>'Y'));

$PROPERTY_VALUE[] = CFile::MakeFileArray($_SERVER["DOCUMENT_ROOT"]."/new_image.jpg");

CIBlockElement::SetPropertyValues($ELEMENT_ID, $IBLOCK_ID, $PROPERTY_VALUE, 'FILES');

for Update it is similar, you need to pass array('VALUE' => array('del'=>'Y'))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question