Last active
May 26, 2017 14:32
-
-
Save wingsryder/0ee478711118630cc5002cd8f4977c60 to your computer and use it in GitHub Desktop.
Clean all magento cache including images and js/css
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 | |
require 'app/Mage.php'; | |
Mage::app('admin')->setUseSessionInUrl(false); | |
Mage::getConfig()->init(); | |
echo "- Initializing cleaning all caches"; | |
$types = Mage::app()->getCacheInstance()->getTypes(); | |
try { | |
echo "- Refreshing data cache.\n"; | |
flush(); | |
foreach ($types as $type => $data) { | |
echo "---- Cleaning $type ... "; | |
echo Mage::app()->getCacheInstance()->clean($data["tags"]) ? "[DONE]" : "[ERROR]"; | |
echo "\n"; | |
} | |
} catch (exception $e) { | |
die("[ERROR:" . $e->getMessage() . "]"); | |
} | |
try { | |
echo "\n- Cleaning stored cache."; | |
flush(); | |
echo Mage::app()->getCacheInstance()->clean() ? "[DONE]" : "[ERROR]"; | |
} catch (exception $e) { | |
die("\n[ERROR:" . $e->getMessage() . "]"); | |
} | |
try { | |
echo "- Cleaning merged JS/CSS."; | |
flush(); | |
Mage::getModel('core/design_package')->cleanMergedJsCss(); | |
Mage::dispatchEvent('clean_media_cache_after'); | |
echo "[DONE]\n\n"; | |
} catch (Exception $e) { | |
die("[ERROR:" . $e->getMessage() . "]"); | |
} | |
try { | |
echo "- Cleaning image cache."; | |
flush(); | |
echo Mage::getModel('catalog/product_image')->clearCache(); | |
echo "[OK]\n"; | |
} catch (exception $e) { | |
die("[ERROR:" . $e->getMessage() . "]"); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment