在Magento EE FPC中打孔Mage_Catalog_Block_Product_Price

Krl*_*arp 5 magento

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

到目前为止,我已成功完成以下任务(他们各自输出测试数据)

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

所以问题是我在容器模型的_getCacheId()和_renderBlock()中结合getCacheKeyInfo()尝试了很多变化,如上所述.但我遇到了绊脚石.如果有人能引导我朝着正确的方向前进,我们将不胜感激.

Chr*_*ris 2

我也一直在努力解决全页缓存问题。
这些是我的发现,对我非常有帮助。

请看:app/code/core/Enterprise/PageCache/Model/Processor/Default.php47号线

 /**
 * 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;
}
Run Code Online (Sandbox Code Playgroud)

看看这个函数,似乎有两种方法可以避免(禁用)全页缓存:

GET 参数:
您可以使用带有三个下划线前缀的参数“store”或“from_store”来避免缓存。例子:

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

Mage::getUrl('catalog/category/view', array('id' => 123, 'query' => array('___store' => '')))
Run Code Online (Sandbox Code Playgroud)

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

Mage::getSingleton('core/session')->setNoCacheFlag(true)
Run Code Online (Sandbox Code Playgroud)