Skip to content

Instantly share code, notes, and snippets.

@SeRGei93
Created August 15, 2021 22:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SeRGei93/212580ef9664111231f82e7c10eea4be to your computer and use it in GitHub Desktop.
Save SeRGei93/212580ef9664111231f82e7c10eea4be to your computer and use it in GitHub Desktop.
Обновление через коллекцию
\Bitrix\Main\Loader::includeModule('iblock');
$iblock = \Bitrix\Iblock\Iblock::wakeUp(3);
$class = $iblock->getEntityDataClass();
$arResult = [];
$elements = $class::getList([
'select' => ['ID', 'IBLOCK_ID', 'XML_ID', 'ARTICLE'],
//'limit' => 5000,
'order' => ['ID' => 'ASC']
])->fetchCollection();
foreach($elements as $element){
$article = $element->getArticle()->getValue();
if ($article != $element->getXmlId()){
$arResult[$element->getId()] = $article;
$element->setXmlId($article);
}
}
$res = $elements->save(true);
if(!$res->isSuccess()){
$errors = $res->getErrorMessages();
print_r($errors);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment