- Модуль: iblock
- Путь к файлу: ~/bitrix/modules/iblock/classes/general/comp_pricetools.php
- Класс: CIBlockPriceTools
- Вызов: CIBlockPriceTools::GetOfferProperties
static function GetOfferProperties($offerID, $iblockID, $propertiesList, $skuTreeProps = '')
{
$iblockInfo = false;
$result = array();
$iblockID = (int)$iblockID;
$offerID = (int)$offerID;
if (0 >= $iblockID || 0 >= $offerID)
return $result;
$skuPropsList = array();
if (!empty($skuTreeProps))
{
if (is_array($skuTreeProps))
{
$skuPropsList = $skuTreeProps;
}
else
{
$skuTreeProps = base64_decode((string)$skuTreeProps);
if (false !== $skuTreeProps && CheckSerializedData($skuTreeProps))
{
$skuPropsList = unserialize($skuTreeProps, ['allowed_classes' => false]);
if (!is_array($skuPropsList))
{
$skuPropsList = array();
}
}
}
}
if (!is_array($propertiesList))
{
$propertiesList = array();
}
if (!empty($skuPropsList))
{
$propertiesList = array_unique(array_merge($propertiesList, $skuPropsList));
}
if (empty($propertiesList))
return $result;
$propCodes = array_fill_keys($propertiesList, true);
if (self::$catalogIncluded === null)
self::$catalogIncluded = Loader::includeModule('catalog');
if (self::$catalogIncluded)
{
$iblockInfo = CCatalogSku::GetInfoByProductIBlock($iblockID);
if (empty($iblockInfo))
{
$iblockInfo = CCatalogSku::GetInfoByOfferIBlock($iblockID);
}
}
if (empty($iblockInfo))
return $result;
$sortIndex = 1;
$rsProps = CIBlockElement::GetProperty(
$iblockInfo['IBLOCK_ID'],
$offerID,
array("sort"=>"asc", "enum_sort" => "asc", "value_id"=>"asc"),
array("EMPTY"=>"N")
);
while ($oneProp = $rsProps->Fetch())
{
if (!isset($propCodes[$oneProp['CODE']]) && !isset($propCodes[$oneProp['ID']]))
continue;
$propID = (isset($propCodes[$oneProp['CODE']]) ? $oneProp['CODE'] : $oneProp['ID']);
$userTypeProp = false;
$userType = null;
if (isset($oneProp['USER_TYPE']) && !empty($oneProp['USER_TYPE']))
{
$userTypeDescr = CIBlockProperty::GetUserType($oneProp['USER_TYPE']);
if (isset($userTypeDescr['GetPublicViewHTML']))
{
$userTypeProp = true;
$userType = $userTypeDescr['GetPublicViewHTML'];
}
}
if ($userTypeProp)
{
$displayValue = (string)call_user_func_array($userType,
array(
$oneProp,
array('VALUE' => $oneProp['VALUE']),
array('MODE' => 'SIMPLE_TEXT')
));
$result[] = array(
"NAME" => $oneProp["NAME"],
"CODE" => $propID,
"VALUE" => $displayValue,
"SORT" => $sortIndex++,
);
}
else
{
switch ($oneProp["PROPERTY_TYPE"])
{
case "S":
case "N":
$result[] = array(
"NAME" => $oneProp["NAME"],
"CODE" => $propID,
"VALUE" => $oneProp["VALUE"],
"SORT" => $sortIndex++,
);
break;
case "G":
$rsSection = CIBlockSection::GetList(
array(),
array("=ID"=>$oneProp["VALUE"]),
false,
array('ID', 'NAME')
);
if ($arSection = $rsSection->Fetch())
{
$result[] = array(
"NAME" => $oneProp["NAME"],
"CODE" => $propID,
"VALUE" => $arSection["NAME"],
"SORT" => $sortIndex++,
);
}
break;
case "E":
$rsElement = CIBlockElement::GetList(
array(),
array("=ID"=>$oneProp["VALUE"]),
false,
false,
array("ID", "NAME")
);
if ($arElement = $rsElement->Fetch())
{
$result[] = array(
"NAME" => $oneProp["NAME"],
"CODE" => $propID,
"VALUE" => $arElement["NAME"],
"SORT" => $sortIndex++,
);
}
break;
case "L":
$result[] = array(
"NAME" => $oneProp["NAME"],
"CODE" => $propID,
"VALUE" => $oneProp["VALUE_ENUM"],
"SORT" => $sortIndex++,
);
break;
}
}
}
return $result;
}