Stand alone Magento scripts

Before running any stand alone scripts that use core Magento objects and functionality, you need to make sure Magento is properly initialised.

Add this snippet to the top of your script, updating the path accordingly.

<?php 
define('PATH_TO_MAGENTO', '/var/www/magento'); // update accordingly
require_once PATH_TO_MAGENTO.'/app/Mage.php';
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); 
 
// your php code here
 
?>

Comments are closed.