Monday 27 November 2017

Magento 1.9 Auto Clean Cash Using Custom Code

Create a php page 'autocleancash.php' with below code.

<?php

ini_set('display_errors', 1);
error_reporting(E_ALL);
//echo 'Hello1';
require_once 'app/Mage.php';


Mage::init();
$types = Mage::app()->getCacheInstance()->getTypes();

try {
    echo "Cleaning data cache... \n";
    flush();
    foreach ($types as $type => $data) {
        echo "Removing $type ... ";
        echo Mage::app()->getCacheInstance()->clean($data["tags"]) ? "Cache cleared!" : "There is some error!";
        echo "\n";
    }
} catch (exception $e) {
    die("[ERROR:" . $e->getMessage() . "]");
}

echo "\n";

try {
    echo "Cleaning stored cache... ";
    flush();
    echo Mage::app()->getCacheInstance()->clean() ? "Cache cleared!" : "There is some error!";
    echo "\n\n";
} catch (exception $e) {
    die("[ERROR:" . $e->getMessage() . "]");
}             

?>



 if any issues please email me.

Thanks,
Kuldeep singh

No comments:

Post a Comment