Skip to content

Instantly share code, notes, and snippets.

@VSeryoga
Last active July 31, 2018 09:28
Show Gist options
  • Save VSeryoga/29a837778bdb95f02271269be3636cce to your computer and use it in GitHub Desktop.
Save VSeryoga/29a837778bdb95f02271269be3636cce to your computer and use it in GitHub Desktop.
Местоположения Битрикс
<?
$res = \Bitrix\Sale\Location\LocationTable::getList(array(
'filter' => array('=NAME.LANGUAGE_ID' => LANGUAGE_ID, 'TYPE_CODE' => array("VILLAGE", "CITY"), 'NAME_RU' => $_POST["city"]."%"),
'select' => array('*', 'NAME_RU' => 'NAME.NAME', 'TYPE_CODE' => 'TYPE.CODE'),
'limit' => 10
));
while($item = $res->fetch())
{
$loc[$item["ID"]] = $item;
$ids[] = $item["PARENT_ID"];
echo Bitrix\Sale\Location\Admin\LocationHelper::getLocationPathDisplay($item["CODE"])."<br>";
}
//"VILLAGE", "CITY" -поселок или город
@sukhikh18
Copy link

Посмотри, здесь могут быть проблемы: $_POST["city"]."%". К Примеру ?city="Ува" помимо "Ува посёлок" найдет еще и: "Уварово".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment