Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Short script to update store urls (based on subdomains)
- * when moving between dev/staging/live servers.
- *
- * Assumes store code is the subdomain and that hyphens (in url) = unserscores (in storecode)
- *
- * Version: 2012.06.08 - 2
- */
- /* Boostrap Magento */
- $mageFilename = '../magento/app/Mage.php';
- if (!file_exists($mageFilename)) {
- die('Mage.php not found');
- }
- require_once $mageFilename;
- Mage::setIsDeveloperMode(true);
- ini_set('display_errors', 1);
- Mage::init();
- /* End Bootstrap */
- $unsecureUrl = parse_url(Mage::getUrl());
- $secureUrl = parse_url(Mage::getUrl('', array('_secure'=>true)));
- foreach(Mage::app()->getStores() as $store) {
- $storeCode = $store->getCode();
- if ($storeCode == 'default') {
- continue;
- }
- $newUnsecure = $unsecureUrl['scheme'] . '://' . str_replace('_', '-', $storeCode) . '.' . $unsecureUrl['host'] . $unsecureUrl['path'];
- $newSecure = $secureUrl['scheme'] . '://' . str_replace('_', '-', $storeCode) . '.' . $secureUrl['host'] . $secureUrl['path'];
- Mage::getConfig()->saveConfig('web/unsecure/base_url', $newUnsecure, 'stores', $store->getId());
- Mage::getConfig()->saveConfig('web/unsecure/base_url', $newSecure, 'stores', $store->getId());
- }
- Mage::app()->getCache()->clean();
Add Comment
Please, Sign In to add comment