我有一段时间来弄清楚代码/参数,以孔插入MAGENTO中的整页高速缓存,用于mage_catalog_block_block_product_price block。我可以得到价格以显示该页面第一次加载的价格,但是当缓存ID唯一时,它并不能正确地呈现价格(当应该被缓存时它确实正确缓存它)。我知道我需要将其发送给参数,例如product_id等,但是不清楚(例如(例如xx')需要从getCacheKeyInfo发送什么(例如xx'),以在$ this-> _ placeholder-> getAttribute('xx')。以及需要准备并从_renderview()发送到价格布局/视图的内容。
到目前为止,我已经成功完成了以下操作(他们每个输出测试数据)
- 在我的模块/ETC文件夹中创建Cache.xml
- 创建了缓存容器模型和经过验证的作品(只需要设置)
- 重新写入/扩展了mage_catalog_block_product_price_price到我自己的模型中添加getCacheKeyInfo()
这样的问题是,我在容器模型的_getCacheId()和_renderBlock()中尝试了许多变体,并与GetCacheKeyInfo()结合使用,如上所述。但是我打了一个绊脚石。如果有人能带领我朝正确的方向前进,那将不胜感激。
我也一直在整个页面缓存。
这些是我的发现,对我很有帮助。
请看一下:app/code/core/Enterprise/PageCache/Model/Processor/Default.php
行47
/**
* Check if request can be cached
*
* @param Zend_Controller_Request_Http $request
* @return bool
*/
public function allowCache(Zend_Controller_Request_Http $request)
{
foreach ($this->_noCacheGetParams as $param) {
if (!is_null($request->getParam($param, null))) {
return false;
}
}
if (Mage::getSingleton('core/session')->getNoCacheFlag()) {
return false;
}
return true;
}
查看此功能似乎有两种避免(禁用)全页缓存的方法:
获取参数:
您可以使用带有三个下划线的前缀的参数'商店"或" from_store"以避免缓存。示例:
http://magentourl.com/catelog/category/view/id/123?___store
Mage::getUrl('catalog/category/view', array('id' => 123, 'query' => array('___store' => '')))
会话变量:
您还可以通过设置(临时)会话变量来避免全页缓存:
Mage::getSingleton('core/session')->setNoCacheFlag(true)