【发布时间】:2012-12-02 08:25:46
【问题描述】:
我使用的是 Magento EE 1.12 版并启用了全页缓存
a) 我的产品详情页面已缓存 b)因此我在此页面中的购物车没有显示动态商品数量 c)所以我无法在我的产品详细信息页面中显示有效的购物车项目数
我遵循的步骤
1) 我创建了一个块并从 header.phtml 调用 2) 试图使 topcart.phtml 块不被缓存
作为 magento 的新手,我得到了一些缓存打孔的链接
我点击了以下链接,但没有成功
我的文件结构
app-code-local-Enterprise-PageCache->etc-cache.xml
和 PageCache - 模型 - 容器 - TopCart.php
代码如下图
我创建了文件 cache.xml 和 cart.php 容器文件
<page_html_topcart>
<block>page/html_topcart</block>
<name>topcart</name>
<placeholder>PAGE_HTML_HEADER_CART</placeholder>
<container>Enterprise_PageCache_Model_Container_TopCart</container>
<cache_lifetime>36400</cache_lifetime>
</page_html_topcart>
这是我的 topcart.php 容器文件的样子
protected function _getIdentifier()
{
$cacheId = $this->_getCookieValue(Enterprise_PageCache_Model_Cookie::COOKIE_CUSTOMER, '')
. '_'
. $this->_getCookieValue(Enterprise_PageCache_Model_Cookie::COOKIE_CUSTOMER_LOGGED_IN, '');
return $cacheId;
}
protected function _getCacheId()
{
return 'CONTAINER_TOPCART_' . md5($this->_placeholder->getAttribute('cache_id') . $this->_getIdentifier());
}
protected function _renderBlock()
{
$block = $this->_getPlaceHolderBlock(); //('page/html_header_cart');
Mage::dispatchEvent('render_block', array('block' => $block, 'placeholder' => $this->_placeholder));
return $block->toHtml();
}
请帮助我提供有用的链接和步骤
【问题讨论】:
-
你的问题不是很清楚,但如果我理解你的问题,你可以将你想要的数据存储在 cookie 中并用 javscript 显示
-
@OSdave 我无法将其存储在 cookie 中,因为它的购物车项目计数显示在标题块中,因为我的产品详细信息页面正在全页缓存中缓存,因此无法使购物车动态化那是我的问题,
-
请看我在另一篇关于 FPC 的帖子中的回答。也许有帮助:stackoverflow.com/questions/12948235/…