Question

I need to get the exact URL when customer visit my site on first time,
It is based on following options

  1. base url that depends on default website,store and store view,
  2. store code to urls enabled or not.

I got the base URL by

$websites = Mage::getModel('core/website')->getCollection()->addFieldToFilter('is_default', 1);
$website = $websites->getFirstItem();
$websiteId = $website->getId();
$websiteCode = $website->getCode();
$baseUrl = Mage::getConfig()->getNode('web/unsecure/base_url', 'website', $websiteCode);

The URL will be appended with store code if store code to urls is enabled in admin.

how to check store code to urls enabled programmatically in magento?

Was it helpful?

Solution

You can check if the store codes are included in the URL like this:

$flag = Mage::getStoreConfigFlag('web/url/use_store');

$flag will be true or false depending on the store codes in URL are enabled or not.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top