Web

Fix 'Your City?' Popup in Bitrix ASPRO Premier 1.8.0

Restore 'Your city?' popup for IP city detection in Bitrix ASPRO Premier 1.8.0. Fix after init.php deletion or template update: recreate init.php, configure Sypex Geo handler, check templates, clear caches.

1 answer 1 view

How to fix the ‘Your city?’ popup for city detection in Bitrix ASPRO Premier 1.8.0? The standard popup stopped working, possibly after deleting the /local/php_interface/init.php file or a template update. Sypexgeo service is enabled in the admin panel under ‘Geolocation handlers list’ with a correct key, but it’s not functioning. What code or configuration is needed to restore it?

To fix the “Your city?” popup in Bitrix ASPRO Premier 1.8.0, recreate the /local/php_interface/init.php file with essential module calls like CMain::Init() and geolocation handlers, then verify Sypex Geo is active with your key in Settings > Product Settings > Geolocation. Deleting init.php or updating the template often breaks city detection by IP, so also check that the bitrix:main.geolocation component outputs correctly in your header or top template files. Clear all caches afterward, and test with a real IP— it’ll snap back into place.


Contents


Bitrix Geolocation Basics in ASPRO Premier

Bitrix handles city detection through its built-in geolocation system, which ASPRO Premier taps into for that handy “Your city?” popup. It pulls from services like Sypex Geo or GeoIP2 to match your visitor’s IP to a city, then stores it in the session for multiregional setups. But when init.php vanishes—maybe from a cleanup gone wrong or a template update—it all grinds to a halt. No session data means no popup.

Why does this matter? Your site visitors expect seamless city switching without manual picks every time. In ASPRO, this ties into multiregionality, showing relevant contacts, prices, or stock based on location. Head to the admin panel first: Settings > Product Settings > Geolocation. Spot Sypex Geo there? Good start. But if the popup’s dead, it’s likely not just the handler—initialization is key.

The official Aspro documentation spells it out: ensure init.php calls CMain::Init() and loads the main module. Without that, even a perfect Sypex key won’t trigger.


Restore the Critical init.php File

Ever deleted a file thinking it’d simplify things, only for the site to break? That’s classic with /local/php_interface/init.php in Bitrix. This bad boy runs early in the request lifecycle, kicking off modules and geolocation magic before templates load.

Create or restore it at /local/php_interface/init.php (not the root /bitrix/php_interface/ one, which affects all sites). Here’s the minimal code to get city detection humming:

php
<?php
if (!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED !== true) die();

CMain::Init(); // Essential for core functionality

// Optional: Explicitly load modules if needed
if (CModule::IncludeModule('main')) {
 // Geolocation will init here via handlers
}

// Save geo data to session if not already
if (!isset($_SESSION['GEOIP'])) {
 // Trigger geolocation manager
 $geoData = \Bitrix\Main\Service\GeoIp\Manager::getDataResult();
 if ($geoData->isSuccess()) {
 $_SESSION['GEOIP'] = $geoData->getGeoData()->toArray();
 }
}
?>

Paste that in, set permissions to 644, and save. The Bitrix dev docs confirm: no sale or geoip module needed for pure Sypex Geo—it works via HTTP requests. But main is non-negotiable.

Pro tip: If vulnerabilities zapped your files (ASPRO had some in 2025), grab a fresh init.php from backups or the Aspro recovery guide.


Configure Sypex Geo Handler Properly

Sypex Geo’s enabled with a key? Great, but double-check it’s firing. In admin: Administration > Settings > Product Settings > Geolocation > Sypex Geo. Tick “Active,” paste your key from sypexgeo.net, and hit the “Additional” tab for tweaks.

Test it right there—Bitrix has a built-in IP tester. No city? Your key might be bunk, or IP blocks are off. The Aspro multiregionality docs stress setting a “Default City” with the checkbox, plus domain aliases and declensions (e.g., “Moscow” → “Москвы” for cases).

For D7 flair, snag city like this in templates:

php
$cityName = \Bitrix\Main\Service\GeoIp\Manager::getCityName(\Bitrix\Main\Service\GeoIp\Manager::getRealIp());
echo $cityName ?: 'Your city?';

Pulls from session if cached. Community breakdowns show this beats manual includes.


Check Template and Component Output

Templates in ASPRO Premier—like header.php or top.php—output the popup via bitrix:main.geolocation. Open yours (usually /bitrix/templates/[template_name]/header.php) and hunt for:

php
<?$APPLICATION->IncludeComponent(
 "bitrix:main.geolocation",
 "",
 array(
 "CACHE_TYPE" => "A",
 // ... other params
 )
);?>

Missing? Add it before </head>. Or check $city = $_SESSION['GEOIP']['cityName'] ?? 'Default City'; and echo in the header. The Aspro header guide confirms IP-city display belongs here.

Updated template? Revert or diff changes—popup scripts like show_basket_popup.php got patched in recent ASPRO versions per security blogs.


Clear Caches and Test City Detection

Bitrix caches aggressively. After fixes: Admin > Performance > Cache Control > Clear All. Also zap opcode and managed caches. Test incognito with tools like whatismyipaddress.com or curl your site with --resolve for foreign IPs.

Popup still ghosting? Log Sypex requests: edit \Bitrix\Main\Service\GeoIp\SypexGeo::sendRequest() per Habr Q&A. Expect getCity($ip) returning arrays like ['city_name' => 'Moscow'] from Sypex docs.

Regional setup? Ensure cities in Content > Regions have “Default” flagged and domains matched.


Troubleshoot Common Pitfalls

Stuck? Here’s the hit list:

  • No session: Add session_start() early in init.php if missing.
  • PHP extensions: Sypex doesn’t need geoip module—ditch it.
  • Updates broke it: Post-Bitrix update, init.php hooks fail; use /local/ overrides.
  • VPS blocks: Firewalls nix Sypex calls—whitelist sypexgeo.net.
  • Multisite: Wrong init.php path? /local/ is site-specific.

For hardcore: Include SxGeo.php manually before bitrix/header.php, but that’s hacky—stick to handlers. Forum threads echo this pain.

Real-world win: One site post-vuln fix via DigitalRocket—upload fixit.php, scan, restore.


Sources

  1. Aspro Official: Multiregionality
  2. Bitrix Dev: Geolocation Handlers
  3. Mrcappuccino: D7 Geolocation
  4. Aspro: Auto-Detection Recovery
  5. Aspro: Region Settings
  6. Aspro: Header City Display
  7. DigitalRocket: Bitrix Vulnerabilities
  8. Seousluga: ASPRO Hacks

Conclusion

Nailing the “Your city?” popup in Bitrix ASPRO Premier 1.8.0 boils down to a solid init.php, active Sypex Geo, and template tweaks—most sites revive in under 30 minutes. Keep regions defaulted, caches cleared, and watch for updates eating files. You’ll have seamless Bitrix geolocation flowing again, boosting that multiregional UX. Test live, tweak as needed, and your visitors won’t even notice the fix.

Authors
Verified by moderation
Moderation
Fix 'Your City?' Popup in Bitrix ASPRO Premier 1.8.0