if(!isset($reqParams[$hlblock['ID']])) { $reqParams[$hlblock['ID']] = array(); $reqParams[$hlblock['ID']]['HLB'] = $hlblock; } $reqParams[$hlblock['ID']]['VALUES'][] = $arProp['VALUE']; } } foreach ($reqParams as $params) { $boolName = true; $boolPict = true; $entity = \Freetrix\Highloadblock\HighloadBlockTable::compileEntity($params['HLB']); $entityDataClass = $entity->getDataClass(); $fieldsList = $entityDataClass::getMap(); $directoryOrder = array(); if (isset($fieldsList['UF_SORT'])) { $directoryOrder['UF_SORT'] = 'ASC'; } $directoryOrder['ID'] = 'ASC'; $arFilter = array( 'order' => $directoryOrder ); if($arResult['ID'] > 0) { $arFilter['filter'] = array(
public static function getTreeProperties($skuInfo, $propertiesCodes, $defaultFields = array()) { $requireFields = array( 'ID', 'UF_XML_ID', 'UF_NAME', ); $result = array(); if (empty($skuInfo)) return $result; if (!is_array($skuInfo)) { $skuInfo = intval($skuInfo); if ($skuInfo <= 0) return $result; if (self::$catalogIncluded === null) self::$catalogIncluded = \Freetrix\Main\Loader::includeModule('catalog'); if (!self::$catalogIncluded) return $result; $skuInfo = CCatalogSKU::GetInfoByProductIBlock($skuInfo); if (empty($skuInfo) || !is_array($skuInfo)) return $result; } if (empty($propertiesCodes) || !is_array($propertiesCodes)) return $result; $showMode = ''; $props = CIBlockProperty::GetList( array('SORT' => 'ASC', 'ID' => 'ASC'), array('IBLOCK_ID' => $skuInfo['IBLOCK_ID'], 'ACTIVE' => 'Y', 'MULTIPLE' => 'N') ); while ($propInfo = $props->Fetch()) { $propInfo['ID'] = intval($propInfo['ID']); if ($propInfo['ID'] == $skuInfo['SKU_PROPERTY_ID']) continue; if ('' == $propInfo['CODE']) $propInfo['CODE'] = $propInfo['ID']; if (!in_array($propInfo['CODE'], $propertiesCodes)) continue; $propInfo['USER_TYPE'] = (string)$propInfo['USER_TYPE']; if ('L' != $propInfo['PROPERTY_TYPE'] && 'E' != $propInfo['PROPERTY_TYPE'] && !('S' == $propInfo['PROPERTY_TYPE'] && 'directory' == $propInfo['USER_TYPE'])) continue; if ('S' == $propInfo['PROPERTY_TYPE'] && 'directory' == $propInfo['USER_TYPE']) { if (!isset($propInfo['USER_TYPE_SETTINGS']['TABLE_NAME']) || empty($propInfo['USER_TYPE_SETTINGS']['TABLE_NAME'])) continue; if (null === self::$highLoadInclude) self::$highLoadInclude = \Freetrix\Main\Loader::includeModule('highloadblock'); if (!self::$highLoadInclude) continue; $highBlock = \Freetrix\Highloadblock\HighloadBlockTable::getList(array("filter" => array('TABLE_NAME' => $propInfo['USER_TYPE_SETTINGS']['TABLE_NAME'])))->fetch(); if (!isset($highBlock['ID'])) continue; $entity = \Freetrix\Highloadblock\HighloadBlockTable::compileEntity($highBlock); $entityDataClass = $entity->getDataClass(); $fieldsList = $entityDataClass::getMap(); if (empty($fieldsList)) continue; $flag = true; foreach ($requireFields as &$fieldCode) { if (!isset($fieldsList[$fieldCode]) || empty($fieldsList[$fieldCode])) { $flag = false; break; } } unset($fieldCode); if (!$flag) continue; $propInfo['USER_TYPE_SETTINGS']['FIELDS_MAP'] = $fieldsList; $propInfo['USER_TYPE_SETTINGS']['ENTITY'] = $entity; } switch ($propInfo['PROPERTY_TYPE']) { case 'E': $showMode = 'PICT'; break; case 'L': $showMode = 'TEXT'; break; case 'S': $showMode = (isset($fieldsList['UF_FILE']) ? 'PICT' : 'TEXT'); break; } $treeProp = array( 'ID' => intval($propInfo['ID']), 'CODE' => $propInfo['CODE'], 'NAME' => $propInfo['NAME'], 'SORT' => intval($propInfo['SORT']), 'PROPERTY_TYPE' => $propInfo['PROPERTY_TYPE'], 'USER_TYPE' => $propInfo['USER_TYPE'], 'LINK_IBLOCK_ID' => $propInfo['LINK_IBLOCK_ID'], 'USER_TYPE_SETTINGS' => $propInfo['USER_TYPE_SETTINGS'], 'VALUES' => array(), 'SHOW_MODE' => $showMode, 'DEFAULT_VALUES' => array( 'PICT' => false, 'NAME' => '-' ) ); if ('PICT' == $showMode) { if (isset($defaultFields['PICT'])) { $treeProp['DEFAULT_VALUES']['PICT'] = $defaultFields['PICT']; } } if (isset($defaultFields['NAME'])) { $treeProp['DEFAULT_VALUES']['NAME'] = $defaultFields['NAME']; } $result[$treeProp['CODE']] = $treeProp; } return $result; }
} if (!empty($arIBlockProperty['VALUE'])) { $arResult[] = $arIBlockProperty; } } else { $arIBlockProperty['VALUE'] = array(); $arConvert = array(); if (isset($arIBlockProperty["USER_TYPE_SETTINGS"]["TABLE_NAME"]) && !empty($arIBlockProperty["USER_TYPE_SETTINGS"]["TABLE_NAME"])) { $hlblock = HL\HighloadBlockTable::getList(array("filter" => array("TABLE_NAME" => $arIBlockProperty["USER_TYPE_SETTINGS"]["TABLE_NAME"])))->fetch(); if (!empty($hlblock) && is_array($hlblock)) { $entity = HL\HighloadBlockTable::compileEntity($hlblock); $entity_data_class = $entity->getDataClass(); $rsData = $entity_data_class::getList(array()); while($arData = $rsData->fetch()) { $arData["VALUE"] = $arData["UF_NAME"]; $arData["PROPERTY_ID"] = $arIBlockProperty["ID"]; $arData["SORT"] = $arData["UF_SORT"]; $arIBlockProperty['VALUE'][] = $arData; $arConvert[$arData["ID"]] = $arData["UF_XML_ID"]; } } } if (!empty($arIBlockProperty['VALUE'])) { $arResult[] = $arIBlockProperty;