Last active
February 21, 2017 01:37
-
-
Save gelanivishal/1f765596257c77f8bc1b7362e4744082 to your computer and use it in GitHub Desktop.
M1 - Clear cache programatically
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//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); | |
try { | |
//CLEAN OVERALL CACHE | |
flush(); | |
Mage::app()->cleanCache(); | |
// CLEAN IMAGE CACHE | |
flush(); | |
Mage::getModel('catalog/product_image')->clearCache(); | |
print 'done'; | |
} | |
catch(Exception $e) { | |
//something went wrong... | |
print($e->getMessage()); | |
} | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//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); | |
$types=array('config','layout','block_html','translate','collections','eav','config_api','config_api2'); | |
foreach($types as $type) { | |
$c = Mage::app()->getCacheInstance()->cleanType($type); | |
Mage::dispatchEvent('adminhtml_cache_refresh_type', array('type' => $type)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment