本文整理汇总了PHP中CSaleLocation::getLocationIdByCODE方法的典型用法代码示例。如果您正苦于以下问题:PHP CSaleLocation::getLocationIdByCODE方法的具体用法?PHP CSaleLocation::getLocationIdByCODE怎么用?PHP CSaleLocation::getLocationIdByCODE使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSaleLocation
的用法示例。
在下文中一共展示了CSaleLocation::getLocationIdByCODE方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetRealValue
function GetRealValue($propertyID, $propertyCode, $propertyType, $value, $lang = false)
{
$propertyID = IntVal($propertyID);
$propertyCode = Trim($propertyCode);
$propertyType = Trim($propertyType);
if ($lang === false)
$lang = LANGUAGE_ID;
$arResult = array();
$curKey = ((strlen($propertyCode) > 0) ? $propertyCode : $propertyID);
if ($propertyType == "SELECT" || $propertyType == "RADIO")
{
$arValue = CSaleOrderPropsVariant::GetByValue($propertyID, $value);
$arResult[$curKey] = $arValue["NAME"];
}
elseif ($propertyType == "MULTISELECT")
{
$curValue = "";
if (!is_array($value))
$value = explode(",", $value);
for ($i = 0, $max = count($value); $i < $max; $i++)
{
if ($arValue1 = CSaleOrderPropsVariant::GetByValue($propertyID, $value[$i]))
{
if ($i > 0)
$curValue .= ",";
$curValue .= $arValue1["NAME"];
}
}
$arResult[$curKey] = $curValue;
}
elseif ($propertyType == "LOCATION")
{
if(CSaleLocation::isLocationProMigrated())
{
$curValue = '';
if(strlen($value))
{
// now we got CODE here
$locationId = CSaleLocation::getLocationIdByCODE($value);
if(intval($locationId))
{
try
{
$locationStreetPropertyValue = '';
$res = \Bitrix\Sale\Location\LocationTable::getPathToNode($locationId, array('select' => array('LNAME' => 'NAME.NAME', 'TYPE_ID'), 'filter' => array('=NAME.LANGUAGE_ID' => LANGUAGE_ID)));
$types = \Bitrix\Sale\Location\Admin\TypeHelper::getTypeCodeIdMapCached();
$path = array();
while($item = $res->fetch())
{
// copy street to STREET property
if($types['ID2CODE'][$item['TYPE_ID']] == 'STREET')
$locationStreetPropertyValue = $item['LNAME'];
$path[] = $item['LNAME'];
}
$curValue = implode(' - ', $path);
if(strlen($locationStreetPropertyValue))
$arResult[$curKey."_STREET"] = $locationStreetPropertyValue;
}
catch(\Bitrix\Main\SystemException $e)
{
}
}
}
}
else
{
$arValue = CSaleLocation::GetByID($value, $lang);
$curValue = $arValue["COUNTRY_NAME"].((strlen($arValue["COUNTRY_NAME"])<=0 || strlen($arValue["REGION_NAME"])<=0) ? "" : " - ").$arValue["REGION_NAME"].((strlen($arValue["COUNTRY_NAME"])<=0 || strlen($arValue["CITY_NAME"])<=0) ? "" : " - ").$arValue["CITY_NAME"];
}
$arResult[$curKey] = $curValue;
$arResult[$curKey."_COUNTRY"] = $arValue["COUNTRY_NAME"];
$arResult[$curKey."_REGION"] = $arValue["REGION_NAME"];
$arResult[$curKey."_CITY"] = $arValue["CITY_NAME"];
}
else
{
$arResult[$curKey] = $value;
}
return $arResult;
}