Skip to content

Instantly share code, notes, and snippets.

@ajankovic
Created November 14, 2012 17:40
Show Gist options
  • Save ajankovic/4073579 to your computer and use it in GitHub Desktop.
Save ajankovic/4073579 to your computer and use it in GitHub Desktop.
Init Magento environment for custom scripts
// I want to see errors
error_reporting(E_ALL);
ini_set('display_errors', '1');
// Modify the PHP Environment
ini_set('memory_limit', '2048M');
// Load Up Magento Core
define('MAGENTO', realpath('..'));
require_once(MAGENTO . '/app/Mage.php');
Mage::setIsDeveloperMode(true);
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
function get_store_by_code($storeCode) {
$stores = array_keys(Mage::app()->getStores());
foreach($stores as $id){
$store = Mage::app()->getStore($id);
if($store->getCode()==$storeCode) {
return $store;
}
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment