Created
August 15, 2021 22:27
-
-
Save SeRGei93/212580ef9664111231f82e7c10eea4be to your computer and use it in GitHub Desktop.
Обновление через коллекцию
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\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