Magento: New url on a existing installation (after a move)

Magento stores the base url in the database.
The easy way to change this is to use the admin interfece, but if that is not possible (for instance you have swapped ip for a dev machine – or moved data from a existing installation to another machine) then it is possible to do the update in the database.

  • In the table “core_config_data” find the keys “web/secure/url” and “web/secure/url” and just update these to the new address. Hint: The addresses should end with “/” otherwise magento won’t like it.
  • Clean out var/cache/* and var/session/* (use “rm -rf” on a *nix environment)

.htaccess to allow google ads (the indexing bot) [or limit user-agents via .htaccess]

Sometimes there is a need to only allow limit access to a site using a .htaccess file.
If you still wish to be able to serve Google adsense on this page then the following example is good for this (yes the allow line should be changed to suit your needs)

# Google_ads agents
BrowserMatchNoCase Mediapartners-Google good_pass
BrowserMatchNoCase Adsbot-Google good_pass
<LIMIT GET POST>
order deny,allow
deny from all
allow from 123.456.789
#Google ads
allow from env=good_pass
</LIMIT>

PHP: casting stdClass Object to a array

When using Soapclient to access a webservice the returned object will be of a stdClass Object.

If you don’t wish to access this as an object, but would find it easier to use it as an array then a quick cast solves this.

/*As an object*/
print_r($soapResult->contents);
/*cast to an array*/
$soapResult = (array)$soapResult;
print_r($soapResult['contents']);