Example #1
0
    $arFields = array("ACTIVE" => "Y", "FIELDS" => array('IBLOCK_SECTION' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'ACTIVE' => array('IS_REQUIRED' => 'Y', 'DEFAULT_VALUE' => 'Y'), 'ACTIVE_FROM' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'ACTIVE_TO' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'SORT' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'NAME' => array('IS_REQUIRED' => 'Y', 'DEFAULT_VALUE' => ''), 'PREVIEW_PICTURE' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => array('FROM_DETAIL' => 'N', 'SCALE' => 'N', 'WIDTH' => '', 'HEIGHT' => '', 'IGNORE_ERRORS' => 'N')), 'PREVIEW_TEXT_TYPE' => array('IS_REQUIRED' => 'Y', 'DEFAULT_VALUE' => 'text'), 'PREVIEW_TEXT' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'DETAIL_PICTURE' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => array('SCALE' => 'N', 'WIDTH' => '', 'HEIGHT' => '', 'IGNORE_ERRORS' => 'N')), 'DETAIL_TEXT_TYPE' => array('IS_REQUIRED' => 'Y', 'DEFAULT_VALUE' => 'text'), 'DETAIL_TEXT' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'XML_ID' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'CODE' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => ''), 'TAGS' => array('IS_REQUIRED' => 'N', 'DEFAULT_VALUE' => '')), "CODE" => $iblockCode, "XML_ID" => $iblockCode);
    $iblock->Update($iblockID, $arFields);
    $arProperties = array("USER", "USER_ACTIVE", "DEPARTMENT", "POST", "STATE");
    foreach ($arProperties as $propertyName) {
        ${$propertyName . "_PROPERTY_ID"} = 0;
        $properties = CIBlockProperty::GetList(array(), array("ACTIVE" => "Y", "IBLOCK_ID" => $iblockID, "CODE" => $propertyName));
        if ($arProperty = $properties->Fetch()) {
            ${$propertyName . "_PROPERTY_ID"} = $arProperty["ID"];
        }
    }
    $aFormOptions = array("tabs" => "edit1--#--" . GetMessage("STATE_FORM_1") . "--,--PROPERTY_" . $USER_PROPERTY_ID . "--#--" . GetMessage("STATE_FORM_2") . "--,--ACTIVE_FROM--#--" . GetMessage("STATE_FORM_3") . "--,--NAME--#--*" . GetMessage("STATE_FORM_4") . "--,--PROPERTY_" . $POST_PROPERTY_ID . "--#--" . GetMessage("STATE_FORM_5") . "--,--PROPERTY_" . $DEPARTMENT_PROPERTY_ID . "--#--" . GetMessage("STATE_FORM_6") . "--,--PROPERTY_" . $STATE_PROPERTY_ID . "--#--" . GetMessage("STATE_FORM_8") . "--,--PREVIEW_TEXT--#--" . GetMessage("STATE_FORM_7") . "--;--");
    WizardServices::SetIBlockFormSettings($iblockID, $aFormOptions);
    if ($DEPARTMENT_PROPERTY_ID > 0) {
        $rsIBlock = CIBlock::GetList(array(), array("CODE" => "departments", "TYPE" => "structure", "SITE_ID" => WIZARD_SITE_ID));
        if ($arIBlock = $rsIBlock->Fetch()) {
            $property = new CIBlockProperty();
            $property->Update($DEPARTMENT_PROPERTY_ID, array("LINK_IBLOCK_ID" => $arIBlock["ID"]));
        }
    }
} else {
    $arSites = array();
    $db_res = CIBlock::GetSite($iblockID);
    while ($res = $db_res->Fetch()) {
        $arSites[] = $res["LID"];
    }
    if (!in_array(WIZARD_SITE_ID, $arSites)) {
        $arSites[] = WIZARD_SITE_ID;
        $iblock = new CIBlock();
        $iblock->Update($iblockID, array("LID" => $arSites));
    }
}
				else
					$PROP_TYPE = "S";

				if($arPriceType[$IBLOCK_XML_ID]==$PROP_XML_ID)
					continue;

				$res = CIBlock::GetProperties($IBLOCK_ID, array(), Array("IBLOCK_ID"=>$IBLOCK_ID, "XML_ID"=>$PROP_XML_ID));
				$bNewRecord_tmp = False;
				if($res_arr = $res->Fetch())
				{
					$PROP_ID = $res_arr["ID"];
					$res = $ibp->Update($PROP_ID,
							Array(
								"NAME" => $PROP_NAME,
								"TYPE" => $PROP_TYPE,
								"MULTIPLE" => $PROP_MULTIPLE,
								"DEFAULT_VALUE" => $PROP_DEF,
								"TMP_ID"		=> $tmpid
							)
						);
				}
				else
				{
					$bNewRecord_tmp = True;
					$arFields = Array(
						"NAME" 			=> $PROP_NAME,
						"ACTIVE" 		=> "Y",
						"SORT" 			=> "500",
						"DEFAULT_VALUE" => $PROP_DEF,
						"XML_ID" 		=> $PROP_XML_ID,
						"TMP_ID"		=> $tmpid,
Example #3
0
 public function updatePropertyIfExists($iblockId, $propertyCode, $fields)
 {
     $propId = $this->getPropertyId($iblockId, $propertyCode);
     if (!$propId) {
         return false;
     }
     $ib = new \CIBlockProperty();
     if ($ib->Update($propId, $fields)) {
         return true;
     }
     $this->throwException(__METHOD__, $ib->LAST_ERROR);
 }
Example #4
0
							$arNewIBlocksList[$intIBlockID]['OFFERS_PROP'] = $mxPropID;
							$arNewIBlocksList[$intIBlockID]['NEED_IS_REQUIRED'] = 'N';
							$arNewIBlocksList[$intIBlockID]['NEED_UPDATE'] = 'N';
							$arNewIBlocksList[$intIBlockID]['NEED_LINK'] = 'N';
						}
					}
					elseif (0 < $arIBlockInfo['OFFERS_PROP'])
					{
						if ('Y' == $arIBlockInfo['NEED_UPDATE'])
						{
							$arPropFields = array(
								'USER_TYPE' => 'SKU',
								'XML_ID' => 'CML2_LINK',
							);
							$obProp = new CIBlockProperty();
							$mxPropID = $obProp->Update($arIBlockInfo['OFFERS_PROP'],$arPropFields);
							if (!$mxPropID)
							{
								$boolFlag = false;
								$strWarning .= Loc::getMessage(
									'CAT_IBLOCK_OFFERS_ERR_MODIFY_PROP_IS_REQ',
									array(
										'#OFFERS#' => $arCurrentIBlocks[$arIBlockInfo['OFFERS_IBLOCK_ID']]['INFO'],
										'#ERR#' => $obProp->LAST_ERROR
									)
								).'<br />';
								break;
							}
						}
					}
				}
Example #5
0
}
$dbSite = CSite::GetByID(WIZARD_SITE_ID);
if ($arSite = $dbSite->Fetch()) {
    $lang = $arSite["LANGUAGE_ID"];
}
if (strlen($lang) <= 0) {
    $lang = "ru";
}
$iblockCodeTheme = "infoportal_theme_" . WIZARD_SITE_ID;
$iblockTypeTheme = "news";
$rsIBlockTheme = CIBlock::GetList(array(), array("XML_ID" => $iblockCodeTheme, "TYPE" => $iblockTypeTheme));
if ($arIBlockTheme = $rsIBlockTheme->Fetch()) {
    $iblockIDTheme = $arIBlockTheme["ID"];
    $arFields = array("LINK_IBLOCK_TYPE_ID" => $iblockTypeTheme, "LINK_IBLOCK_ID" => $iblockIDTheme, "USER_TYPE" => "EAutocomplete", "USER_TYPE_SETTINGS" => array("MAX_WIDTH" => 250, "SHOW_ADD" => "Y", "IBLOCK_MESS" => "Y"));
    $ibprop = new CIBlockProperty();
    $ibprop->Update($arProperty["THEME"], $arFields);
    if ($lang == 'ru') {
        $arThemeElement = array("277" => array("254", "253"), "256" => array("259", "258", "255"));
    } elseif ($lang == 'en') {
        $arThemeElement = array("161" => array("1", "8", "92"), "163" => array("169", "88", "89", "93"));
    } elseif ($lang == 'de') {
        $arThemeElement = array("161" => array("35", "88", "77"), "163" => array("38", "83", "82", "166"));
    }
    foreach ($arThemeElement as $ThemeID => $ThemeElements) {
        $rsElemetTheme = CIBlockElement::GetList(array("show_counter" => "desc"), array("XML_ID" => $ThemeID, "IBLOCK_ID" => $iblockIDTheme));
        if ($arElemetTheme = $rsElemetTheme->Fetch()) {
            $elementIDTheme = $arElemetTheme["ID"];
            foreach ($ThemeElements as $ElementID) {
                $rsElemet = CIBlockElement::GetList(array("show_counter" => "desc"), array("XML_ID" => $ElementID, "IBLOCK_ID" => $iblockID), false, false, array("ID"));
                if ($arElemet = $rsElemet->Fetch()) {
                    CIBlockElement::SetPropertyValuesEx($arElemet["ID"], $iblockID, array("THEME" => $elementIDTheme));
Example #6
0
function CheckSKUProperty($ID, $SKUID)
{
    $arResult = false;
    $ID = (int) $ID;
    $SKUID = (int) $SKUID;
    if ($ID > 0 && $SKUID > 0) {
        $intSKUPropID = 0;
        $ibp = new CIBlockProperty();
        $arProp = GetSKUProperty($ID, $SKUID);
        if (empty($arProp) || is_array($arProp) && $arProp['MULTIPLE'] != 'N') {
            $arOFProperty = array('NAME' => GetMessage('IB_E_OF_SKU_PROPERTY_NAME'), 'IBLOCK_ID' => $SKUID, 'PROPERTY_TYPE' => Iblock\PropertyTable::TYPE_ELEMENT, 'USER_TYPE' => CIBlockPropertyTools::USER_TYPE_SKU_LINK, 'LINK_IBLOCK_ID' => $ID, 'ACTIVE' => 'Y', 'SORT' => '5', 'MULTIPLE' => 'N', 'CODE' => CIBlockPropertyTools::CODE_SKU_LINK, 'XML_ID' => CIBlockPropertyTools::XML_SKU_LINK, 'FILTRABLE' => 'Y', 'SEARCHABLE' => 'N');
            $intSKUPropID = $ibp->Add($arOFProperty);
            if (!$intSKUPropID) {
                $arResult = array('RESULT' => 'ERROR', 'MESSAGE' => $ibp->LAST_ERROR);
            }
        } elseif ($arProp['USER_TYPE'] != CIBlockPropertyTools::USER_TYPE_SKU_LINK || $arProp['XML_ID'] != CIBlockPropertyTools::XML_SKU_LINK) {
            $arFields = array('USER_TYPE' => CIBlockPropertyTools::USER_TYPE_SKU_LINK, 'XML_ID' => CIBlockPropertyTools::XML_SKU_LINK);
            $boolFlag = $ibp->Update($arProp['ID'], $arFields);
            if (false === $boolFlag) {
                $arResult = array('RESULT' => 'ERROR', 'MESSAGE' => $ibp->LAST_ERROR);
            } else {
                $intSKUPropID = $arProp['ID'];
            }
        } else {
            $intSKUPropID = $arProp['ID'];
        }
        $intSKUPropID = (int) $intSKUPropID;
        if ($intSKUPropID > 0) {
            $arResult = array('RESULT' => 'OK', 'VALUE' => $intSKUPropID);
        }
    } else {
        $arResult = array('RESULT' => 'ERROR', 'MESSAGE' => GetMessage('IB_E_OF_ERR_SKU_IBLOCKS_IS_ABSENT'));
    }
    return $arResult;
}
Example #7
0
	/**
	 * [updateProperties description]
	 * @param  object $obprop
	 * @param  integer $sortKey
	 * @return array
	 */
	protected function updateProperties($obprop, $prop, $sortKey){
		if (!CModule::IncludeModule("iblock")):
			return false; 
		endif;
		$arFields = array();
		$name = null; $id1c = null;
		$name = $obprop->Наименование;
		$id1c = $obprop->Ид;
		$arFields = $this->bildArrFields($obprop, $sortKey);
		$ibp = new CIBlockProperty;
		if(!$ibp->Update($prop['ID'], $arFields)):
			return false;
		endif;
		return true;
	}
Example #8
0
    $db_res = CIBlock::GetSite($iblockID);
    while ($res = $db_res->Fetch()) {
        $arSites[] = $res["LID"];
    }
    if (!in_array(WIZARD_SITE_ID, $arSites)) {
        $arSites[] = WIZARD_SITE_ID;
        $iblock = new CIBlock();
        $iblock->Update($iblockID, array("LID" => $arSites));
    }
}
for ($t = 1; $t <= 7; $t++) {
    $res = CIBlockProperty::GetByID("TAB_" . $t . "_TYPE", $iblockID, false);
    if ($ar_res = $res->GetNext()) {
        $arFields2 = array('USER_TYPE_SETTINGS' => array('size' => '1', 'width' => '0', 'group' => 'N', 'multiple' => 'N', 'TABLE_NAME' => 'tab'), 'USER_TYPE' => 'directory');
        $ibp = new CIBlockProperty();
        $ibp->Update($ar_res['ID'], $arFields2);
    }
}
WizardServices::ReplaceMacrosRecursive(WIZARD_SITE_PATH . "about/", array("REVIEWS_IBLOCK_ID" => $iblockID));
WizardServices::ReplaceMacrosRecursive(WIZARD_SITE_PATH . "about/obzor/", array("REVIEWS_IBLOCK_ID" => $iblockID));
WizardServices::ReplaceMacrosRecursive(WIZARD_SITE_PATH . "ajax/", array("REVIEWS_IBLOCK_ID" => $iblockID));
WizardServices::ReplaceMacrosRecursive(WIZARD_SITE_PATH . "auth/", array("REVIEWS_IBLOCK_ID" => $iblockID));
WizardServices::ReplaceMacrosRecursive(WIZARD_SITE_PATH . "brands/", array("REVIEWS_IBLOCK_ID" => $iblockID));
WizardServices::ReplaceMacrosRecursive(WIZARD_SITE_PATH . "catalog/", array("REVIEWS_IBLOCK_ID" => $iblockID));
WizardServices::ReplaceMacrosRecursive(WIZARD_SITE_PATH . "include/", array("REVIEWS_IBLOCK_ID" => $iblockID));
WizardServices::ReplaceMacrosRecursive(WIZARD_SITE_PATH . "personal/", array("REVIEWS_IBLOCK_ID" => $iblockID));
WizardServices::ReplaceMacrosRecursive(WIZARD_SITE_PATH . "news/", array("REVIEWS_IBLOCK_ID" => $iblockID));
WizardServices::ReplaceMacrosRecursive(WIZARD_SITE_PATH . "sales/", array("REVIEWS_IBLOCK_ID" => $iblockID));
WizardServices::ReplaceMacrosRecursive(WIZARD_SITE_PATH . "search/", array("REVIEWS_IBLOCK_ID" => $iblockID));
CWizardUtil::ReplaceMacros(WIZARD_SITE_PATH . "_index.php", array("REVIEWS_IBLOCK_ID" => $iblockID));
CWizardUtil::ReplaceMacros(WIZARD_SITE_PATH . ".actions.menu.php", array("REVIEWS_IBLOCK_ID" => $iblockID));
 /**
  * @param $data
  * @param null $dbVersion
  * @throws \Exception
  * @return ApplyResult
  */
 public function applySnapshot($data, $dbVersion = null)
 {
     $data = $this->handleNullValues($data);
     $prop = new \CIBlockProperty();
     $res = new ApplyResult();
     $extId = $data['ID'];
     if ($dbVersion) {
         $data['IBLOCK_ID'] = $this->getReferenceController()->getCurrentIdByOtherVersion($data['IBLOCK_ID'], ReferenceController::GROUP_IBLOCK, $dbVersion);
         $id = $this->getCurrentVersionId($extId, $dbVersion);
     } else {
         $id = $extId;
     }
     if (!$dbVersion && !PropertyTable::getById($id)->fetch()) {
         unset($data['VERSION']);
         $addRes = PropertyTable::add(array('ID' => $id, 'NAME' => $data['NAME'], 'IBLOCK_ID' => $data['IBLOCK_ID']));
         if (!$addRes->isSuccess()) {
             throw new \Exception('Ќе удалось возобновить свойство текущей версии. ' . implode(', ', $addRes->getErrorMessages()) . "\n" . var_export($data, true));
         }
     }
     if ($id && PropertyTable::getById($id)->fetch()) {
         $res->setSuccess((bool) $prop->Update($id, $data));
     } else {
         $res->setSuccess((bool) ($id = $prop->Add($data)));
         $this->registerCurrentVersionId($id, $this->getReferenceValue($extId, $dbVersion));
     }
     $res->setId($id);
     if ($data['PROPERTY_TYPE'] == self::LIST_TYPE_SIGN && !empty($data['~property_list_values'])) {
         $this->_applyPropertyListTypeValues($id, $data['~property_list_values']);
     }
     return $res->setMessage($prop->LAST_ERROR);
 }
Example #10
0
     $arFields["VALUES"] = $arListValues;
 }
 if (COption::GetOptionString("iblock", "show_xml_id", "N") == "Y") {
     $arFields["XML_ID"] = $_POST["PROPERTY_XML_ID"];
 }
 if (CIBlock::GetArrayByID($arFields["IBLOCK_ID"], "SECTION_PROPERTY") === "N") {
     if ($arFields["SECTION_PROPERTY"] === "N" || $arFields["SMART_FILTER"] === "Y") {
         $ib = new CIBlock();
         $ib->Update($arFields["IBLOCK_ID"], array("SECTION_PROPERTY" => "Y"));
     }
 }
 $ibp = new CIBlockProperty();
 if ($propID > 0) {
     $arFields['PROPERTY_TYPE'] = $arProp['PROPERTY_TYPE'];
     $arFields['USER_TYPE'] = $arProp['USER_TYPE'];
     $res = $ibp->Update($propID, $arFields, true);
 } else {
     $propID = intval($ibp->Add($arFields));
 }
 if ($propID <= 0) {
     $errMsg .= $ibp->LAST_ERROR;
     $bVarsFromForm = true;
     if ($e = $APPLICATION->GetException()) {
         $errMsg .= $e->GetString() . '<br>';
     }
 } else {
     if (isset($_POST['apply'])) {
         LocalRedirect(CComponentEngine::makePathFromTemplate($arParams['PATH_TO_PRODUCTPROPS_EDIT'], array('prop_id' => $propID)));
     } else {
         LocalRedirect(CComponentEngine::makePathFromTemplate($arParams['PATH_TO_PRODUCTPROPS_LIST']));
     }
Example #11
0
 /**
  * @var string $iblock
  * @var array $data
  * @var bool $deleteIfExists
  */
 protected function IblockPropertyUpdate($iblock, array $data)
 {
     $ibId = $this->IblockGetIdByCode($iblock);
     if (empty($data['CODE'])) {
         throw new \Exception('You must set property CODE');
     }
     if ($ibId) {
         $fire = false;
         $res = \CIBlockProperty::GetList([], ['CODE' => $data['CODE'], 'IBLOCK_ID' => $ibId, 'CHECK_PERMISSIONS' => 'N']);
         if ($ob = $res->Fetch()) {
             $ib = new \CIBlockProperty();
             $id = $ib->Update($ob['ID'], $data);
             if ($id) {
                 echo "Update {$data['CODE']} iblock property\r\n";
             } else {
                 throw new \Exception("Can't update {$data['CODE']} iblock property");
             }
         } else {
             throw new \Exception("Can't find {$data['CODE']} iblock property");
         }
     } else {
         throw new \Exception("Can't find iblock {$iblock}");
     }
 }
 public function updatePropertyById($propertyId, $fields)
 {
     if (!empty($fields['VALUES']) && !isset($fields['PROPERTY_TYPE'])) {
         $fields['PROPERTY_TYPE'] = 'L';
     }
     if (!empty($fields['LINK_IBLOCK_ID']) && !isset($fields['PROPERTY_TYPE'])) {
         $fields['PROPERTY_TYPE'] = 'E';
     }
     if (false !== strpos($fields['PROPERTY_TYPE'], ':')) {
         list($ptype, $utype) = explode(':', $fields['PROPERTY_TYPE']);
         $fields['PROPERTY_TYPE'] = $ptype;
         $fields['USER_TYPE'] = $utype;
     }
     $ib = new \CIBlockProperty();
     if ($ib->Update($propertyId, $fields)) {
         return true;
     }
     $this->throwException(__METHOD__, $ib->LAST_ERROR);
 }
Example #13
0
 /**
  *
  */
 public function process()
 {
     if ($this->processed) {
         return;
     }
     $this->processed = true;
     foreach ($this->generateData() as $k => $v) {
         $this->data[$k] = $v;
     }
     $this->update();
     $o = new \CIBlock();
     $mesages = $this->messages();
     $o->SetMessages($this->getId(), $mesages);
     $fields = $this->fields();
     $o->SetFields($this->getId(), $fields);
     $props = $this->loadProperties();
     $newProps = $this->properties();
     foreach ($this->urlsProps() as $key => $data) {
         $newProps[$key] = $data;
     }
     $o = new \CIBlockProperty();
     foreach ($props as $prop => $data) {
         if (!isset($newProps[$prop])) {
             $o->Delete($data['ID']);
         }
     }
     foreach ($newProps as $prop => $data) {
         $data['CODE'] = $prop;
         if ($data['PROPERTY_TYPE'] == 'E' || $data['PROPERTY_TYPE'] == 'G') {
             if (!isset($data['LINK_IBLOCK_ID'])) {
                 if (isset($data['LINK_IBLOCK_CODE'])) {
                     $data['LINK_IBLOCK_ID'] = self::codeToId($data['LINK_IBLOCK_CODE']);
                 }
             }
         }
         if (isset($props[$prop])) {
             $id = $props[$prop]['ID'];
             $o->Update($id, $data);
         } else {
             $data['IBLOCK_ID'] = $this->getId();
             $id = $o->Add($data);
         }
         if ($data['PROPERTY_TYPE'] == 'L' && isset($data['ITEMS']) && is_array($data['ITEMS'])) {
             $items = array();
             $newItems = $data['ITEMS'];
             $res = \CIBlockPropertyEnum::GetList(array(), array('PROPERTY_ID' => $id, 'CHECK_PERMISSIONS' => 'N'));
             while ($row = $res->Fetch()) {
                 $iid = $row['ID'];
                 $eid = $row['EXTERNAL_ID'];
                 if (!isset($newItems[$eid])) {
                     \CIBlockPropertyEnum::Delete($iid);
                 } else {
                     $items[$eid] = $row;
                 }
             }
             $eo = new \CIBlockPropertyEnum();
             foreach ($newItems as $eid => $edata) {
                 if (is_string($edata)) {
                     $edata = array('VALUE' => $edata);
                 }
                 $edata['PROPERTY_ID'] = $id;
                 $edata['EXTERNAL_ID'] = $eid;
                 $edata['XML_ID'] = $eid;
                 if (isset($items[$eid])) {
                     $eo->Update($items[$eid]['ID'], $edata);
                 } else {
                     $eo->Add($edata);
                 }
             }
         }
     }
 }
     </form>
     <?
     break;
 case 2:
     $PROPERTY_ID = $_REQUEST['PROPERTY_ID'];
     $IBLOCK_ID = $_REQUEST['IBLOCK_ID'];
     $arFields = array("PROPERTY_TYPE" => "L");
     foreach($_SESSION['PROP_VALUES_UNIQUE'] as $value) {
         $arFields["VALUES"][] = array(
             "VALUE" => $value,
             "DEF" => "N",
             "SORT" => "100"
        );   
     } 
     $ibp = new CIBlockProperty;
     if(!$ibp->Update($PROPERTY_ID, $arFields)) { 
         ShowError($ibp->LAST_ERROR);
     } else {
         $db_enum_list = CIBlockProperty::GetPropertyEnum($PROPERTY_ID, Array(), Array("IBLOCK_ID" => $IBLOCK_ID));
         while($ar_enum_list = $db_enum_list->GetNext()) {
             $propNameToId[$ar_enum_list['VALUE']] = $ar_enum_list['ID'];
         }
         foreach($_SESSION['PROP_VALUES'] as $elementId => $value) {
             CIBlockElement::SetPropertyValuesEx($elementId, $IBLOCK_ID, array($PROPERTY_ID => $propNameToId[$value]));
         } 
     } 
     echo 'Готово'; 
     break;
 default: ?>
     <script>
         $(function () {
Example #15
0
         }
         foreach ($arID as $id) {
             if (strlen($id) <= 0) {
                 continue;
             }
             switch ($action) {
                 case "delete":
                     if (!CIBlockProperty::Delete($id)) {
                         $errorMsg .= GetMessage("CRM_PRODUCT_PROP_PL_DELETE_ERROR", array("#ID#" => $id)) . '<br>';
                     }
                     break;
                 case "activate":
                 case "deactivate":
                     $ibp = new CIBlockProperty();
                     $arFields = array("ACTIVE" => $action == "activate" ? "Y" : "N");
                     if (!$ibp->Update($id, $arFields)) {
                         $errorMsg .= GetMessage("CRM_PRODUCT_PROP_PL_SAVE_ERROR", array("#ID#" => $id, "#ERROR_TEXT#" => $ibp->LAST_ERROR)) . '<br>';
                     }
                     break;
             }
         }
     }
 }
 if (!empty($errorMsg)) {
     ShowError($errorMsg);
 }
 unset($_GET['ID'], $_POST['ID'], $_REQUEST['ID']);
 // otherwise the filter will work
 /*if(!isset($_POST['AJAX_CALL']))
 	{
 		LocalRedirect($APPLICATION->GetCurPage());
 /**
  * @param int $id
  * @param array $arFields
  *
  * @throws MigrationException
  */
 protected function updateProperty($id, array $arFields)
 {
     if (!$this->iBlockPropertyGateway->Update($id, $arFields)) {
         throw new MigrationException($this->iBlockPropertyGateway->LAST_ERROR);
     }
 }
Example #17
0
			}
			COption::SetOptionString($module_id, $name, $val, $arOption[1]);
		}
		
		if(count($_REQUEST['IB_P_NAME'] > 0))
		{
			$IB_P_NAME = $_REQUEST['IB_P_NAME'];
			$IB_P_HINT = $_REQUEST['IB_P_HINT'];
			$IB_P_SORT = $_REQUEST['IB_P_SORT'];
			
			foreach($IB_P_NAME AS $IB_P_K => $IB_P_V)
			{
				$iBp = new CIBlockProperty;
				$iBp->Update($IB_P_K, Array(
					"NAME" => $IB_P_NAME[$IB_P_K],
					"HINT" => $IB_P_HINT[$IB_P_K],
					"SORT" => $IB_P_SORT[$IB_P_K],
				));
			}			
		}
	}
	
	ob_start();
	$Update = $Update.$Apply;
	require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/admin/group_rights.php");
	ob_end_clean();
	
	if(strlen($_REQUEST["back_url_settings"]) > 0)
	{
		if((strlen($Apply) > 0) OR (strlen($RestoreDefaults) > 0))
		{
Example #18
0
function CheckSKUProperty($ID, $SKUID)
{
    $arResult = false;
    $ID = intval($ID);
    $SKUID = intval($SKUID);
    if (0 < $ID && 0 < $SKUID) {
        $intSKUPropID = 0;
        $ibp = new CIBlockProperty();
        $arProp = GetSKUProperty($ID, $SKUID);
        if (false === $arProp || true == is_array($arProp) && 'N' != $arProp['MULTIPLE']) {
            $arOFProperty = array('NAME' => GetMessage('IB_E_OF_SKU_PROPERTY_NAME'), 'IBLOCK_ID' => $SKUID, 'PROPERTY_TYPE' => 'E', 'USER_TYPE' => 'SKU', 'LINK_IBLOCK_ID' => $ID, 'ACTIVE' => 'Y', 'SORT' => '5', 'MULTIPLE' => 'N', 'CODE' => 'CML2_LINK', 'XML_ID' => 'CML2_LINK', "FILTRABLE" => "Y", "SEARCHABLE" => "N");
            $intSKUPropID = $ibp->Add($arOFProperty);
            if (!$intSKUPropID) {
                $arResult = array('RESULT' => 'ERROR', 'MESSAGE' => $ibp->LAST_ERROR);
            }
        } elseif ('SKU' != $arProp['USER_TYPE'] || 'CML2_LINK' != $arProp['XML_ID']) {
            $arFields = array('USER_TYPE' => 'SKU', 'XML_ID' => 'CML2_LINK');
            $boolFlag = $ibp->Update($arProp['ID'], $arFields);
            if (false === $boolFlag) {
                $arResult = array('RESULT' => 'ERROR', 'MESSAGE' => $ibp->LAST_ERROR);
            } else {
                $intSKUPropID = $arProp['ID'];
            }
        } else {
            $intSKUPropID = $arProp['ID'];
        }
        if (0 < intval($intSKUPropID)) {
            $arResult = array('RESULT' => 'OK', 'VALUE' => $intSKUPropID);
        }
    } else {
        $arResult = array('RESULT' => 'ERROR', 'MESSAGE' => GetMessage('IB_E_OF_ERR_SKU_IBLOCKS_IS_ABSENT'));
    }
    return $arResult;
}
Example #19
0
 public static function LinkSKUIBlock($ID, $SKUID)
 {
     global $APPLICATION;
     global $DB;
     $arMsg = array();
     $boolResult = true;
     $intSKUPropID = 0;
     $ibp = new CIBlockProperty();
     $ID = (int) $ID;
     if (0 >= $ID) {
         $arMsg[] = array('id' => 'PRODUCT_IBLOCK_ID', 'text' => Loc::getMessage('BT_MOD_CATALOG_ERR_PRODUCT_ID_INVALID'));
         $boolResult = false;
     }
     $SKUID = (int) $SKUID;
     if (0 >= $SKUID) {
         $arMsg[] = array('id' => 'OFFERS_IBLOCK_ID', 'text' => Loc::getMessage('BT_MOD_CATALOG_ERR_OFFERS_ID_INVALID'));
         $boolResult = false;
     }
     if ($ID == $SKUID) {
         $arMsg[] = array('id' => 'OFFERS_IBLOCK_ID', 'text' => Loc::getMessage('BT_MOD_CATALOG_ERR_PRODUCT_ID_SELF'));
         $boolResult = false;
     }
     if ($boolResult) {
         $arSKUProp = false;
         $rsProps = CIBlockProperty::GetList(array(), array('IBLOCK_ID' => $SKUID, 'PROPERTY_TYPE' => 'E', 'LINK_IBLOCK_ID' => $ID, 'ACTIVE' => 'Y'));
         while ($arProp = $rsProps->Fetch()) {
             if (is_array($arProp) && 'N' == $arProp['MULTIPLE']) {
                 $arSKUProp = $arProp;
                 break;
             }
         }
         if (false === $arSKUProp || is_array($arSKUProp) && 'N' != $arSKUProp['MULTIPLE']) {
             $arOFProperty = array('NAME' => Loc::getMessage('BT_MOD_CATALOG_MESS_SKU_PROP_NAME'), 'IBLOCK_ID' => $SKUID, 'PROPERTY_TYPE' => 'E', 'USER_TYPE' => 'SKU', 'LINK_IBLOCK_ID' => $ID, 'ACTIVE' => 'Y', 'SORT' => '5', 'MULTIPLE' => 'N', 'CODE' => 'CML2_LINK', 'XML_ID' => 'CML2_LINK', "FILTRABLE" => "Y", "SEARCHABLE" => "N");
             $intSKUPropID = $ibp->Add($arOFProperty);
             if (!$intSKUPropID) {
                 $arMsg[] = array('id' => 'SKU_PROPERTY_ID', 'text' => str_replace('#ERROR#', $ibp->LAST_ERROR, Loc::getMessage('BT_MOD_CATALOG_ERR_CREATE_SKU_PROPERTY')));
                 $boolResult = false;
             }
         } elseif ('SKU' != $arSKUProp['USER_TYPE'] || 'CML2_LINK' != $arProp['XML_ID']) {
             $arFields = array('USER_TYPE' => 'SKU', 'XML_ID' => 'CML2_LINK');
             $boolFlag = $ibp->Update($arSKUProp['ID'], $arFields);
             if (false === $boolFlag) {
                 $arMsg[] = array('id' => 'SKU_PROPERTY_ID', 'text' => str_replace('#ERROR#', $ibp->LAST_ERROR, Loc::getMessage('BT_MOD_CATALOG_ERR_UPDATE_SKU_PROPERTY')));
                 $boolResult = false;
             } else {
                 $intSKUPropID = $arSKUProp['ID'];
             }
         } else {
             $intSKUPropID = $arSKUProp['ID'];
         }
     }
     if (!$boolResult) {
         $obError = new CAdminException($arMsg);
         $APPLICATION->ResetException();
         $APPLICATION->ThrowException($obError);
         return $boolResult;
     } else {
         CCatalogSKU::ClearCache();
         return $intSKUPropID;
     }
 }
Example #20
0
 function GetPropertyXML_ID($IBLOCK_ID, $NAME, $PROPERTY_ID, $XML_ID)
 {
     if (strlen($XML_ID) <= 0) {
         $XML_ID = $PROPERTY_ID;
         $obProperty = new CIBlockProperty();
         $rsProperty = $obProperty->GetList(array(), array("IBLOCK_ID" => $IBLOCK_ID, "XML_ID" => $XML_ID));
         while ($rsProperty->Fetch()) {
             $XML_ID = md5(uniqid(mt_rand(), true));
             $rsProperty = $obProperty->GetList(array(), array("IBLOCK_ID" => $IBLOCK_ID, "XML_ID" => $XML_ID));
         }
         $obProperty->Update($PROPERTY_ID, array("NAME" => $NAME, "XML_ID" => $XML_ID));
     }
     return $XML_ID;
 }
Example #21
0
     $ipropValues = new \Bitrix\Iblock\InheritedProperty\IblockValues($ID);
     $ipropValues->clearValues();
 }
 /********************/
 $ibp = new CIBlockProperty();
 foreach ($arProperties as $property_id => $arProperty) {
     $property_id = (int) $property_id;
     $arProperty["IBLOCK_ID"] = $ID;
     if ($property_id > 0) {
         if (isset($arProperty['DEL']) && $arProperty['DEL'] == 'Y') {
             if (!CIBlockProperty::Delete($property_id) && ($ex = $APPLICATION->GetException())) {
                 $strWarning .= GetMessage("IB_E_PROPERTY_ERROR") . ": " . $ex->GetString() . "<br>";
                 $bVarsFromForm = true;
             }
         } else {
             $res = $ibp->Update($property_id, $arProperty);
             if (!$res) {
                 $strWarning .= GetMessage("IB_E_PROPERTY_ERROR") . ": " . $ibp->LAST_ERROR . "<br>";
                 $bVarsFromForm = true;
             }
         }
     } else {
         $PropID = (int) $ibp->Add($arProperty);
         if ($PropID <= 0) {
             $strWarning .= $ibp->LAST_ERROR . "<br>";
             $bVarsFromForm = true;
         }
     }
 }
 /*******************************************/
 if (!CIBlockSectionPropertyLink::HasIBlockLinks($ID)) {
    }
    foreach ($arID as $ID) {
        if (strlen($ID) <= 0) {
            continue;
        }
        switch ($_REQUEST['action']) {
            case "delete":
                if (!CIBlockProperty::Delete($ID)) {
                    $lAdmin->AddGroupError(GetMessage("IBP_ADM_DELETE_ERROR"), $ID);
                }
                break;
            case "activate":
            case "deactivate":
                $ibp = new CIBlockProperty();
                $arFields = array("ACTIVE" => $_REQUEST['action'] == "activate" ? "Y" : "N");
                if (!$ibp->Update($ID, $arFields)) {
                    $lAdmin->AddUpdateError(GetMessage("IBP_ADM_SAVE_ERROR", array("#ID#" => $ID, "#ERROR_TEXT#" => $ibp->LAST_ERROR)), $ID);
                }
                break;
        }
    }
}
$arHeader = array(array("id" => "ID", "content" => GetMessage("IBP_ADM_ID"), "sort" => "ID", "align" => "right", "default" => true), array("id" => "NAME", "content" => GetMessage("IBP_ADM_NAME"), "sort" => "NAME", "default" => true), array("id" => "CODE", "content" => GetMessage("IBP_ADM_CODE"), "sort" => "CODE", "default" => true), array("id" => "PROPERTY_TYPE", "content" => GetMessage("IBP_ADM_PROPERTY_TYPE"), "sort" => "PROPERTY_TYPE", "default" => true), array("id" => "SORT", "content" => GetMessage("IBP_ADM_SORT"), "sort" => "SORT", "align" => "right", "default" => true), array("id" => "ACTIVE", "content" => GetMessage("IBP_ADM_ACTIVE"), "sort" => "ACTIVE", "align" => "center", "default" => true), array("id" => "IS_REQUIRED", "content" => GetMessage("IBP_ADM_IS_REQUIRED"), "sort" => "IS_REQUIRED", "align" => "center", "default" => true), array("id" => "MULTIPLE", "content" => GetMessage("IBP_ADM_MULTIPLE"), "sort" => "MULTIPLE", "align" => "center", "default" => true), array("id" => "SEARCHABLE", "content" => GetMessage("IBP_ADM_SEARCHABLE"), "sort" => "SEARCHABLE", "align" => "center", "default" => true), array("id" => "FILTRABLE", "content" => GetMessage("IBP_ADM_FILTRABLE"), "sort" => "FILTRABLE", "align" => "center"), array("id" => "XML_ID", "content" => GetMessage("IBP_ADM_XML_ID"), "sort" => "XML_ID"), array("id" => "WITH_DESCRIPTION", "content" => GetMessage("IBP_ADM_WITH_DESCRIPTION"), "sort" => "WITH_DESCRIPTION", "align" => "center"), array("id" => "HINT", "content" => GetMessage("IBP_ADM_HINT")));
$arPropType = array(Iblock\PropertyTable::TYPE_STRING => GetMessage("IBLOCK_PROP_S"), Iblock\PropertyTable::TYPE_NUMBER => GetMessage("IBLOCK_PROP_N"), Iblock\PropertyTable::TYPE_LIST => GetMessage("IBLOCK_PROP_L"), Iblock\PropertyTable::TYPE_FILE => GetMessage("IBLOCK_PROP_F"), Iblock\PropertyTable::TYPE_SECTION => GetMessage("IBLOCK_PROP_G"), Iblock\PropertyTable::TYPE_ELEMENT => GetMessage("IBLOCK_PROP_E"));
$arUserTypeList = CIBlockProperty::GetUserType();
Main\Type\Collection::sortByColumn($arUserTypeList, array('DESCRIPTION' => SORT_STRING));
foreach ($arUserTypeList as $arUserType) {
    $arPropType[$arUserType["PROPERTY_TYPE"] . ":" . $arUserType["USER_TYPE"]] = $arUserType["DESCRIPTION"];
}
$lAdmin->AddHeaders($arHeader);
$selectFields = array_fill_keys($lAdmin->GetVisibleHeaderColumns(), true);
Example #23
0
 public static function ImportPropsFromXML($BID, $xmlPath, &$arOldNewID)
 {
     if (file_exists($xmlPath) && $BID && CModule::IncludeModule('iblock')) {
         require_once $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/classes/general/xml.php';
         $arExistProps = array();
         $rsProp = CIBlockProperty::GetList(array(), array('IBLOCK_ID' => $BID));
         while ($arProp = $rsProp->Fetch()) {
             $arExistProps[$arProp['CODE']] = $arProp;
         }
         $arExistEnums = array();
         $rsEnum = CIBlockPropertyEnum::GetList(array(), array('IBLOCK_ID' => $BID));
         while ($arEnum = $rsEnum->Fetch()) {
             $arExistEnums[$arEnum['PROPERTY_ID'] . '_' . $arEnum['XML_ID']] = $arEnum;
         }
         $arOldNewID = array();
         $xml = new CDataXML();
         $ep = new CIBlockProperty();
         $en = new CIBlockPropertyEnum();
         if ($xml->Load($xmlPath)) {
             if ($node = $xml->SelectNodes('/asd_iblock_props/props/')) {
                 foreach ($node->children() as $child) {
                     $arProp = array_pop($child->__toArray());
                     $arFields = array('IBLOCK_ID' => $BID);
                     foreach ($arProp as $code => $v) {
                         $arFields[strtoupper($code)] = is_array($v[0]['#']['cdata-section']) ? $v[0]['#']['cdata-section'][0]['#'] : $v[0]['#'];
                     }
                     if (isset($arExistProps[$arFields['CODE']])) {
                         $arOldNewID[$arFields['OLD_ID']] = $arExistProps[$arFields['CODE']]['ID'];
                         $ep->Update($arExistProps[$arFields['CODE']]['ID'], $arFields);
                     } else {
                         $arOldNewID[$arFields['OLD_ID']] = $arFields['ID'] = $ep->Add($arFields);
                         $arExistProps[$arFields['CODE']] = $arFields;
                     }
                 }
             }
             if ($node = $xml->SelectNodes('/asd_iblock_props/enums/')) {
                 foreach ($node->children() as $child) {
                     $arProp = array_pop($child->__toArray());
                     $arFields = array('IBLOCK_ID' => $BID);
                     foreach ($arProp as $code => $v) {
                         $arFields[strtoupper($code)] = is_array($v[0]['#']['cdata-section']) ? $v[0]['#']['cdata-section'][0]['#'] : $v[0]['#'];
                     }
                     $arFields['PROPERTY_ID'] = $arExistProps[$arFields['PROPERTY_CODE']]['ID'];
                     if (isset($arExistEnums[$arFields['PROPERTY_ID'] . '_' . $arFields['XML_ID']])) {
                         $en->Update($arExistEnums[$arFields['PROPERTY_ID'] . '_' . $arFields['XML_ID']]['ID'], $arFields);
                     } else {
                         $en->Add($arFields);
                     }
                 }
             }
         }
     }
 }
Example #24
0
 public function Update($arFields)
 {
     if (isset($arFields["TYPE"])) {
         $newType = $arFields["TYPE"];
     } else {
         $newType = $this->GetTypeID();
     }
     if (is_array($this->_property) && !CListFieldTypeList::IsField($newType)) {
         foreach ($this->GetArray() as $id => $val) {
             if (array_key_exists($id, $arFields) && $id != "IBLOCK_ID") {
                 $this->_property[$id] = $arFields[$id];
             }
         }
         if (strpos($newType, ":") !== false) {
             list($this->_property["PROPERTY_TYPE"], $this->_property["USER_TYPE"]) = explode(":", $newType);
         } else {
             $this->_property["PROPERTY_TYPE"] = $newType;
             $this->_property["USER_TYPE"] = "";
         }
         $this->_property["CHECK_PERMISSIONS"] = "N";
         $this->_property["ACTIVE"] = "Y";
         $obProperty = new CIBlockProperty();
         if ($obProperty->Update($this->_property["ID"], $this->_property)) {
             if ($this->_property["PROPERTY_TYPE"] == "L" && is_array($arFields["LIST"])) {
                 CList::UpdatePropertyList($this->_property["ID"], $arFields["LIST"]);
             }
             return new CListPropertyField($this->_property["IBLOCK_ID"], "PROPERTY_" . $this->_property["ID"], $arFields["NAME"], $arFields["SORT"]);
         }
     }
     return null;
 }
Example #25
0
 */
$conversionProperty = function ($idProperty, $idIBlock, $type) {
    $propertyValues = array();
    $result = CIBlockElement::GetList(array(), array('IBLOCK_ID' => $idIBlock), null, null, array('ID'));
    $variants = array();
    while ($element = $result->Fetch()) {
        $propResult = CIBlockElement::GetProperty($idIBlock, $element['ID'], '', '', array('ID' => $idProperty));
        while ($property = $propResult->Fetch()) {
            $propertyValues[] = array('id_element' => (int) $element['ID'], 'id_property' => (int) $property['ID'], 'value' => $property['VALUE']);
            $variants[] = $property['VALUE'];
        }
    }
    $variants = array_filter(array_unique($variants));
    asort($variants);
    $prop = new CIBlockProperty();
    $prop->Update($idProperty, array('PROPERTY_TYPE' => $type));
    $propertyData = CIBlockProperty::GetByID($idProperty, $idIBlock)->Fetch();
    $list = array();
    switch ($type) {
        case "L":
            // list
            /** @var CDatabase $DB */
            global $DB;
            foreach ($variants as $variant) {
                $lastId = $list[$variant] = CIBlockPropertyEnum::Add(array('PROPERTY_ID' => $idProperty, 'VALUE' => $variant));
                if (!$lastId) {
                    throw new Exception($DB->db_Error);
                }
            }
            break;
        case "E":
 }
 if (!empty($arListValues)) {
     $arFields["VALUES"] = $arListValues;
 }
 if (COption::GetOptionString("iblock", "show_xml_id", "N") == "Y") {
     $arFields["XML_ID"] = $_POST["PROPERTY_XML_ID"];
 }
 if (CIBlock::GetArrayByID($arFields["IBLOCK_ID"], "SECTION_PROPERTY") != "Y") {
     if ($arFields["SECTION_PROPERTY"] === "N" || $arFields["SMART_FILTER"] === "Y") {
         $ib = new CIBlock();
         $ib->Update($arFields["IBLOCK_ID"], array("SECTION_PROPERTY" => "Y"));
     }
 }
 $ibp = new CIBlockProperty();
 if ($str_PROPERTY_ID > 0) {
     $res = $ibp->Update($str_PROPERTY_ID, $arFields, true);
 } else {
     $str_PROPERTY_ID = $ibp->Add($arFields);
     $res = $str_PROPERTY_ID > 0;
     if (!$res) {
         $str_PROPERTY_ID = 'n0';
     }
 }
 if (!$res) {
     $strWarning .= $ibp->LAST_ERROR;
     $bVarsFromForm = true;
     if ($e = $APPLICATION->GetException()) {
         $message = new CAdminMessage(GetMessage("admin_lib_error"), $e);
     }
 } else {
     if (strlen($apply) <= 0) {
Example #27
0
 protected function innerUpdate($id, &$fields, &$errors, array $params = null)
 {
     /** @global CMain $APPLICATION */
     global $APPLICATION;
     if (!CModule::IncludeModule('iblock')) {
         throw new RestException('Could not load iblock module.');
     }
     /** @var CCrmPerms $userPerms */
     $userPerms = CCrmPerms::GetCurrentUserPermissions();
     if (!$userPerms->HavePerm('CONFIG', BX_CRM_PERM_CONFIG, 'WRITE')) {
         $errors[] = 'Access denied.';
         return false;
     }
     $iblockId = intval(CCrmCatalog::EnsureDefaultExists());
     $userTypes = CCrmProductPropsHelper::GetPropsTypesByOperations(false, 'rest');
     $res = CIBlockProperty::GetByID($id, $iblockId);
     $prop = false;
     if (is_object($res)) {
         $prop = $res->Fetch();
     }
     unset($res);
     if (!is_array($prop) || isset($prop['USER_TYPE']) && !empty($prop['USER_TYPE']) && !array_key_exists($prop['USER_TYPE'], $userTypes)) {
         $errors[] = 'Not found';
         return false;
     }
     $fields['IBLOCK_ID'] = $iblockId;
     $fields['PROPERTY_TYPE'] = $prop['PROPERTY_TYPE'];
     $fields['USER_TYPE'] = $prop['USER_TYPE'];
     if (isset($fields['USER_TYPE_SETTINGS']) && is_array($fields['USER_TYPE_SETTINGS'])) {
         $userTypeSettings = array();
         foreach ($fields['USER_TYPE_SETTINGS'] as $key => $value) {
             $userTypeSettings[strtolower($key)] = $value;
         }
         $fields['USER_TYPE_SETTINGS'] = $userTypeSettings;
         unset($userTypeSettings);
     }
     if ($prop['PROPERTY_TYPE'] === 'L' && isset($fields['VALUES']) && is_array($fields['VALUES'])) {
         $values = array();
         $newKey = 0;
         foreach ($fields['VALUES'] as $key => $value) {
             if (!is_array($value) || !isset($value['VALUE']) || '' == trim($value['VALUE'])) {
                 continue;
             }
             $values[0 < intval($key) ? $key : 'n' . $newKey] = array('ID' => 0 < intval($key) ? $key : 'n' . $newKey, 'VALUE' => strval($value['VALUE']), 'XML_ID' => isset($value['XML_ID']) ? strval($value['XML_ID']) : '', 'SORT' => isset($value['SORT']) ? intval($value['SORT']) : 500, 'DEF' => isset($value['DEF']) ? $value['DEF'] === 'Y' ? 'Y' : 'N' : 'N');
             $newKey++;
         }
         $fields['VALUES'] = $values;
         unset($values);
     }
     $property = new CIBlockProperty();
     $result = $property->Update($id, $fields);
     if (!$result) {
         if (!empty($property->LAST_ERROR)) {
             $errors[] = $property->LAST_ERROR;
         } else {
             if ($e = $APPLICATION->GetException()) {
                 $errors[] = $e->GetString();
             }
         }
     }
     return $result;
 }