Sometimes you want to run some code to see what it does, dump an object out or check a class but the thing you want to run/dump/check is hidden deep in the bowels of the code somewhere, and you feel it might be easier to run a bit of PHP to check just that one thing, without having to fire up or your browser, or wait for cron to run - that's where this sandbox script comes in.
To use either of the examples below, save them into a file in the root of your magento install called
sandbox.php, then either browse to the directory and run
php -f sandbox.php or visit
To run the default store:
Mage::app(); // your code
To act as cron:
$_SERVER['SCRIPT_NAME'] = str_replace(basename(__FILE__), 'index.php', $_SERVER['SCRIPT_NAME']); $_SERVER['SCRIPT_FILENAME'] = str_replace(basename(__FILE__), 'index.php', $_SERVER['SCRIPT_FILENAME']); Mage::app('admin')->setUseSessionInUrl(false); Mage::getConfig()->init()->loadEventObservers('crontab'); Mage::app()->addEventArea('crontab'); // your code