Created
February 1, 2013 14:26
-
-
Save jacquesbh/4691599 to your computer and use it in GitHub Desktop.
Change hints in Magento quickly ;)
This file contains 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 | |
defined('__DIR__') || define('__DIR__', dirname(__FILE__)); | |
// Inclure Mage | |
require_once __DIR__ . '/../app/Mage.php'; | |
// Init Mage | |
Mage::app('admin')->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); | |
// Websites | |
$websites = Mage::app()->getWebsites(true, true); | |
function isActive($store) | |
{ | |
return (bool) $store->getConfig('dev/debug/template_hints'); | |
} | |
function change($storeCode, $active) | |
{ | |
$store = Mage::app()->getStore($storeCode); | |
Mage::getConfig()->saveConfig('dev/debug/template_hints', (int) (bool) $active, 'stores', $store->getId()); | |
Mage::getConfig()->saveConfig('dev/debug/template_hints_blocks', (int) (bool) $active, 'stores', $store->getId()); | |
Mage::app()->cleanCache(array('CONFIG', 'BLOCK_HTML', 'FPC')); | |
if (class_exists('Enterprise_PageCache_Model_Cache')) { | |
Enterprise_PageCache_Model_Cache::getCacheInstance()->flush(); | |
} | |
} | |
if (isset($_POST['store_code'], $_POST['value'])) { | |
change($_POST['store_code'], $_POST['value']); | |
header('Content-Type: application/json'); | |
echo json_encode(array('store' => $_POST['store_code'], 'value' => $_POST['value'])); | |
exit; | |
} | |
?> | |
<!DOCTYPE HTML> | |
<html lang="en-US"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Change hints</title> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script> | |
<script type="text/javascript"> | |
(function ($) { | |
$(document).ready( function () { | |
$('input').click(function () { | |
var $input = $(this); | |
var cssClass = $input.hasClass('yes') ? 'yes' : 'no'; | |
$.ajax('<?php echo './' . basename(__FILE__); ?>', { | |
type: 'POST', | |
data: { | |
store_code: $input.attr('rel'), | |
value: $input.val() | |
}, | |
dataType: 'json', | |
success: function (data, textStatus, jqXHR) | |
{ | |
} | |
}); | |
}); | |
}); | |
})(jQuery); | |
</script> | |
</head> | |
<body> | |
<form> | |
<?php foreach ($websites as $website): ?> | |
<fieldset> | |
<legend><?php echo $website->getName(); ?></legend> | |
<?php foreach ($website->getStores() as $store): ?> | |
<fieldset> | |
<legend><?php echo $store->getName(); ?></legend> | |
<label><input type="radio" value="1" class="yes" rel="<?php echo $store->getCode(); ?>" name="<?php echo $store->getCode(); ?>"<?php if ($b = isActive($store)): ?> checked="checked"<?php endif; ?> /> YES</label> | |
<label><input type="radio" value="0" class="no" rel="<?php echo $store->getCode(); ?>" name="<?php echo $store->getCode(); ?>"<?php if (!$b): ?> checked="checked"<?php endif; ?> /> NO</label> | |
</fieldset> | |
<?php endforeach; ?> | |
</fieldset> | |
<?php endforeach; ?> | |
</form> | |
<p style="text-align: center;"><a href="#" onclick="window.location.reload()" style="color: #ccc; text-decoration: none;"><small>refresh</small></a></p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment