Answer the question
In order to leave comments, you need to log in
Bitrix, how to change ELEMENT_XML_ID?
I can't figure out how to change ELEMENT_XML_ID. My products were imported from another site and their article number is filled in this field. I have an Xml export from 1C, I run it and try to fill in the ELEMENT_XML_ID field for the product. Nothing works. Tell me how to do it right? I don’t know Bitrix at all, I know how to use documentation and Google.
What I managed to get:
$xml = new SimpleXMLElement($importCatalogData,LIBXML_NOENT);
foreach ($xml->Каталог->Товары->Товар as $xmlItem){
$sku = trim((string)$xmlItem->Артикул);
$name = trim((string)$xmlItem->Наименование);
$importId = trim((string)$xmlItem->Ид);
if($sku != ''){
$db_res = CCatalogProduct::GetList(false,array("ELEMENT_XML_ID" => "{$sku}"));
while ($ar_res = $db_res->Fetch()){
//echo $ar_res['ELEMENT_IBLOCK_ID']." - ".$ar_res['ID']." - ".$importId." - ".$ar_res["ELEMENT_NAME"]."<br>";
CIBlockElement::SetPropertyValuesEx($ar_res['ID'], false, array('ELEMENT_XML_ID'=>$importId));
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question