Y
Y
Yuriy2021-03-30 10:25:12
1C-Bitrix
Yuriy, 2021-03-30 10:25:12

Why doesn't \Bitrix\Iblock\ElementTable::update work?

\Bitrix\Iblock\ElementTable::update(
     	$arData['PRODUCT_ID'],
     	[
     		'MODIFIED_BY'    => COption::GetOptionString(self::MODULE_ID, 'AGENT_OPTIONS_USER_MODIFY'),
     		'TIMESTAMP_X'	=> $arData['TIMESTAMP_X']
     	]
    );


I get an error:

Для изменения элементов инфоблоков используйте вызов CIBlockElement::Update()


documentation https://dev.1c-bitrix.ru/api_d7/bitrix/iblock/elem...

update (available from 15.0.7)

\Bitrix\Main\Entity\UpdateResult public static
\Bitrix\Iblock\ElementTable::update(
 mixed $primary,
 array $data
);


what's wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Gritsuk, 2021-03-30
@winer

Removed the ability to use add/remove/update operations for IS elements (table \Bitrix\Iblock\ElementTable) through the D7 kernel in the kernel. When updating an IB element, you need to change quite a lot of data in other tables (search indexes, facets, etc.). Therefore, in the bitrix/modules/iblock/lib/element.php code, you can see the following:

public static function add(array $data)
  {
    $result = new ORM\Data\AddResult();
    $result->addError(new ORM\EntityError(
      Loc::getMessage('ELEMENT_ENTITY_MESS_ADD_BLOCKED')
    ));
    return $result;
  }

public static function update($primary, array $data)
  {
    $result = new ORM\Data\UpdateResult();
    $result->addError(new ORM\EntityError(
      Loc::getMessage('ELEMENT_ENTITY_MESS_UPDATE_BLOCKED')
    ));
    return $result;
  }

  public static function delete($primary)
  {
    $result = new ORM\Data\DeleteResult();
    $result->addError(new ORM\EntityError(
      Loc::getMessage('ELEMENT_ENTITY_MESS_DELETE_BLOCKED')
    ));
    return $result;
  }

The documentation for the method explicitly states:
The method is disabled. Use the CIBlockElement::Update method

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question