Advertisement
Guest User

Cleancache.php

a guest
Aug 2nd, 2016
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.36 KB | None | 0 0
  1. <?php
  2. date_default_timezone_set("Europe/Madrid");
  3. echo "Start Cleaning all caches at ... " . date("Y-m-d H:i:s") . "\n\n";
  4. ini_set("display_errors", 1);
  5.  
  6.  
  7. require 'app/Mage.php';
  8. Mage::app('admin')->setUseSessionInUrl(false);
  9. Mage::getConfig()->init();
  10. $types = Mage::app()->getCacheInstance()->getTypes();
  11.  
  12. try {
  13.     echo "Cleaning data cache... \n";
  14.     flush();
  15.     foreach ($types as $type => $data) {
  16.         echo "Removing $type ... ";
  17.         echo Mage::app()->getCacheInstance()->clean($data["tags"]) ? "[OK]" : "[ERROR]";
  18.         echo "\n";
  19.     }
  20. } catch (exception $e) {
  21.     die("[ERROR:" . $e->getMessage() . "]");
  22. }
  23.  
  24. echo "\n";
  25.  
  26. try {
  27.     echo "Cleaning stored cache... ";
  28.     flush();
  29.     echo Mage::app()->getCacheInstance()->clean() ? "[OK]" : "[ERROR]";
  30.     echo "\n\n";
  31. } catch (exception $e) {
  32.     die("[ERROR:" . $e->getMessage() . "]");
  33. }
  34.  
  35. try {
  36.     echo "Cleaning merged JS/CSS...";
  37.     flush();
  38.     Mage::getModel('core/design_package')->cleanMergedJsCss();
  39.     Mage::dispatchEvent('clean_media_cache_after');
  40.     echo "[OK]\n\n";
  41. } catch (Exception $e) {
  42.     die("[ERROR:" . $e->getMessage() . "]");
  43. }
  44.  
  45. try {
  46.     echo "Cleaning image cache... ";
  47.     flush();
  48.     echo Mage::getModel('catalog/product_image')->clearCache();
  49.     echo "[OK]\n";
  50. } catch (exception $e) {
  51.     die("[ERROR:" . $e->getMessage() . "]");
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement