Skip to content

Instantly share code, notes, and snippets.

@sergoslav
Created January 28, 2013 15:53
Show Gist options
  • Save sergoslav/4656645 to your computer and use it in GitHub Desktop.
Save sergoslav/4656645 to your computer and use it in GitHub Desktop.
easyAjax fiseing cahce layout
/**
* Load custom layout
*
* @return Mage_Core_Model_Layout
*/
protected function _loadCustomLayouts()
{
$layout = Mage::app()->getLayout();
$update = $layout->getUpdate();
// load default custom handle
$update->addHandle('easy_ajax_default');
// load action handle
$fullActionName = Mage::app()->getRequest()->getRequestedRouteName() . '_' .
Mage::app()->getRequest()->getRequestedControllerName() . '_' .
Mage::app()->getRequest()->getRequestedActionName();
$update->addHandle('easy_ajax_' . strtolower($fullActionName));
if (Mage::app()->useCache('layout')){
$cacheId = $update->getCacheId().'_easy_ajax';
$update->setCacheId($cacheId);
if (!Mage::app()->loadCache($cacheId)) {
foreach ($update->getHandles() as $handle) {
$update->merge($handle);
}
$update->saveCache();
} else {
//load updates from cache
$update->load();
}
} else {
//load updates
$update->load();
}
//generate xml
$layout->generateXml();
//generate layout blocks
$layout->generateBlocks();
return $layout;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment