- Модуль: iblock
- Путь к файлу: ~/bitrix/modules/iblock/classes/general/cml2.php
- Класс: CIBlockCMLImport
- Вызов: CIBlockCMLImport::CheckProperty
function CheckProperty($IBLOCK_ID, $code, $xml_name)
{
$obProperty = new CIBlockProperty;
$rsProperty = $obProperty->GetList(array(), array("IBLOCK_ID"=>$IBLOCK_ID, "XML_ID"=>$code));
$dbProperty = $rsProperty->Fetch();
if(!$dbProperty)
{
$arProperty = array(
"IBLOCK_ID" => $IBLOCK_ID,
"NAME" => is_array($xml_name)? $xml_name["NAME"]: $xml_name,
"CODE" => $code,
"XML_ID" => $code,
"MULTIPLE" => "N",
"PROPERTY_TYPE" => "S",
"ACTIVE" => "Y",
);
if(is_array($xml_name))
{
foreach($xml_name as $name => $value)
$arProperty[$name] = $value;
}
$ID = $obProperty->Add($arProperty);
if(!$ID)
return $obProperty->LAST_ERROR;
}
elseif (is_array($xml_name))
{
$update = array();
foreach($xml_name as $name => $value)
{
if (($name != "NAME") && ($dbProperty[$name] != $value))
{
$update[$name] = $value;
}
}
if ($update)
{
$obProperty->Update($dbProperty["ID"], $update);
}
}
return true;
}