Guest User

Untitled

a guest
Oct 18th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * Short script to update store urls (based on subdomains)
  5. * when moving between dev/staging/live servers.
  6. *
  7. * Assumes store code is the subdomain and that hyphens (in url) = unserscores (in storecode)
  8. *
  9. * Version: 2012.06.08 - 2
  10. */
  11.  
  12.  
  13. /* Boostrap Magento */
  14. $mageFilename = '../magento/app/Mage.php';
  15. if (!file_exists($mageFilename)) {
  16. die('Mage.php not found');
  17. }
  18.  
  19. require_once $mageFilename;
  20.  
  21. Mage::setIsDeveloperMode(true);
  22. ini_set('display_errors', 1);
  23.  
  24. Mage::init();
  25.  
  26. /* End Bootstrap */
  27.  
  28. $unsecureUrl = parse_url(Mage::getUrl());
  29. $secureUrl = parse_url(Mage::getUrl('', array('_secure'=>true)));
  30.  
  31. foreach(Mage::app()->getStores() as $store) {
  32.  
  33. $storeCode = $store->getCode();
  34. if ($storeCode == 'default') {
  35. continue;
  36. }
  37.  
  38. $newUnsecure = $unsecureUrl['scheme'] . '://' . str_replace('_', '-', $storeCode) . '.' . $unsecureUrl['host'] . $unsecureUrl['path'];
  39. $newSecure = $secureUrl['scheme'] . '://' . str_replace('_', '-', $storeCode) . '.' . $secureUrl['host'] . $secureUrl['path'];
  40.  
  41. Mage::getConfig()->saveConfig('web/unsecure/base_url', $newUnsecure, 'stores', $store->getId());
  42. Mage::getConfig()->saveConfig('web/unsecure/base_url', $newSecure, 'stores', $store->getId());
  43. }
  44.  
  45. Mage::app()->getCache()->clean();
Add Comment
Please, Sign In to add comment