冲孔法师_产品目录_模块_产品_Magento EE FPC中的价格

问题描述:

我花了一点时间来找出代码/参数,以便为Mage_Catalog_Block_Product_Price块在magento中打孔全页缓存.我可以得到显示第一次加载页面时的价格,但是当缓存ID是唯一的时,它就无法正确呈现价格(应该缓存的时候它确实可以正确缓存).我知道我需要向其发送参数,例如product_id等,但不清楚需要从getCacheKeyInfo将哪些内容(例如"xx")发送到缓存容器中,以便在$ this-> _ placeholder-> getAttribute('xx'中使用) ).以及需要准备什么并将其从_renderView()发送到价格布局/视图.

I'm having a heck of a time figuring out the code/parameters to hole-punch the Full Page Cache in magento for the Mage_Catalog_Block_Product_Price block. I can get the price to show the first time the page is loaded, but when the cache id is unique, it's not rendering the price properly (it does cache it correctly when it's supposed to be cached) . I know I need to send it parameters, such as product_id etc, but not clear about what (eg 'xx') needs to be sent from getCacheKeyInfo into the cache container for use in $this->_placeholder->getAttribute('xx'). And what needs to be prepared and sent from _renderView() to the price layout/view.

到目前为止,我已经成功完成了以下操作(它们各自输出测试数据)

So far I have done the following successfully (they each output testing data)

  • 在我的模块/etc文件夹中创建了cache.xml
  • 创建了缓存容器模型并验证了工作(仅需要设置)
  • 将Mage_Catalog_Block_Product_Price重写/扩展到我自己的模型中,以添加getCacheKeyInfo()

所以问题是如上所述,我已经尝试将容器模型的_getCacheId()和_renderBlock()与getCacheKeyInfo()结合使用许多变体.但是我遇到了绊脚石.如果有人可以引导我朝正确的方向前进,将不胜感激.

So the problem is that I have tried many variations within the container model's _getCacheId() and _renderBlock() in combination with the getCacheKeyInfo(), like described above. But I am hitting a stumbling block. If anyone can lead me in the right direction, it would be greatly appreciated.

我也一直在全页缓存方面苦苦挣扎.
这些是我的发现,对我很有帮助.

I've been struggling with the Full Page Caching as well.
These are my findings and have been very helpful to me.

请查看: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;
}

使用此功能,似乎有两种避免(禁用)全页缓存的方法:

Looking at this function there seem to be two ways of avoiding (disabling) the Full Page Cache:

GET参数:
您可以在参数'store'或'from_store'前面加上三个下划线来避免缓存. 示例:

GET Parameter:
You can use the parameters 'store' or 'from_store' prefixed with three underscores to avoid the cache. Example:

http://magentourl.com/catelog/category/view/id/123?___store

Mage::getUrl('catalog/category/view', array('id' => 123, 'query' => array('___store' => '')))

会话变量:
您还可以通过设置(临时)会话变量来避免全页缓存:

Session variable:
You could also avoid the Full Page caching by setting a (temporary) session variable:

Mage::getSingleton('core/session')->setNoCacheFlag(true)