简体   繁体   English

在Magento EE FPC中打孔Mage_Catalog_Block_Product_Price

[英]Hole punching Mage_Catalog_Block_Product_Price in Magento EE FPC

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. 我有一段时间搞清楚Mage_Catalog_Block_Product_Price块的magento全页缓存的代码/参数。 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) . 我可以在第一次加载页面时显示价格,但是当缓存ID是唯一的时,它不能正确地呈现价格(当它应该被缓存时它会正确地缓存它)。 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'). 我知道我需要发送它的参数,例如product_id等,但不清楚需要从getCacheKeyInfo发送什么(例如'xx')到缓存容器中以便在$ this中使用 - > _ placeholder-> getAttribute('xx' )。 And what needs to be prepared and sent from _renderView() to the price layout/view. 还有什么需要准备并从_renderView()发送到价格布局/视图。

So far I have done the following successfully (they each output testing data) 到目前为止,我已成功完成以下任务(他们各自输出测试数据)

  • Created the cache.xml in my module /etc folder 在我的module / etc文件夹中创建了cache.xml
  • Created the cache container model and verified works (just need settings) 创建缓存容器模型并验证工作(只需要设置)
  • Rewrote/extended the Mage_Catalog_Block_Product_Price into my own model to add the getCacheKeyInfo() 将Mage_Catalog_Block_Product_Price重写/扩展到我自己的模型中以添加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. 所以问题是我在容器模型的_getCacheId()和_renderBlock()中结合getCacheKeyInfo()尝试了很多变化,如上所述。 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. 这些是我的发现,对我很有帮助。

Please take a look at: app/code/core/Enterprise/PageCache/Model/Processor/Default.php Line 47 请看一下: 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 Parameter: GET参数:
You can use the parameters 'store' or 'from_store' prefixed with three underscores to avoid the cache. 您可以使用前缀为三个下划线的参数'store'或'from_store'来避免缓存。 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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM