Skip to content

Instantly share code, notes, and snippets.

@mklooss
Last active December 14, 2015 23:49
Show Gist options
  • Select an option

  • Save mklooss/5168369 to your computer and use it in GitHub Desktop.

Select an option

Save mklooss/5168369 to your computer and use it in GitHub Desktop.
Magento: Change URL
<?php
// BOF: Config
// Syntax have to be "http(s)://something.com/"
// Slash at the End is required
$http = "http://www.example.com/";
$https = "https://www.example.com/";
// EOF: Config
/* Magento Move Shop */
$dir = dirname(__FILE__);
chdir($dir);
require $dir.'/app/Mage.php';
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$types = Mage::app()->getCacheInstance()->getTypes();
foreach($types as $_type)
{
// clear invalid caches
Mage::app()->getCacheInstance()->cleanType($_type->getId());
}
Mage::getModel('core/config')->saveConfig('web/unsecure/base_url',$http,'default',0);
Mage::getModel('core/config')->saveConfig('web/secure/base_url',$https,'default',0);
Mage::getConfig()->reinit();
Mage::app()->reinitStores();
$types = Mage::app()->getCacheInstance()->getTypes();
foreach($types as $_type)
{
// clear invalid caches
Mage::app()->getCacheInstance()->cleanType($_type->getId());
}
echo "<h3>DONE</h3>";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment