Skip to content

Instantly share code, notes, and snippets.

@hslatman
Last active September 16, 2015 09:17
Show Gist options
  • Save hslatman/9df207719054ea5beadd to your computer and use it in GitHub Desktop.
Save hslatman/9df207719054ea5beadd to your computer and use it in GitHub Desktop.
Clear Magento cache
<?php
/******************************************************************************************************************
* Source: http://www.emvee-solutions.com/blog/magento-clear-cache-programatically/
*
* Clearing the Magento cache programmatically
******************************************************************************************************************/
//increase execution time
ini_set('max_execution_time', 900); //900 seconds = 15 minutes
//require Magento
require_once 'app/Mage.php';
$app = Mage::app('admin');
umask(0);
//enable Error Reporting
error_reporting(E_ALL & ~E_NOTICE);
Mage::setIsDeveloperMode(true);
try {
//CLEAN OVERALL CACHE
flush();
Mage::app()->cleanCache();
// CLEAN IMAGE CACHE
flush();
Mage::getModel('catalog/product_image')->clearCache();
//print
print 'done';
}
catch(Exception $e){
//something went wrong...
print($e->getMessage());
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment