在magento商店中挖掘标题

Ash*_*ame 11 magento

我已经在magento中实现了头部的打孔,即使我已经按照每个客户的方式进行了工作,我也需要通过使其在diff cart项目计数上工作来更深入地使用这一级别.

这是我的代码.

class AD_PageCache_Model_Container_Header extends Enterprise_PageCache_Model_Container_Abstract {

    protected function _getIdentifier() {
        return $this->_getCookieValue(Enterprise_PageCache_Model_Cookie::COOKIE_CUSTOMER, '');
    }

    // public function getCacheKeyInfo() {
    //  $info = parent::getCacheKeyInfo();
    //  die('boo');
    //  $info['cart_count'] = Mage::helper( 'checkout/cart' )->getCart()->getItemsCount();

    //  return $info;
    // }

    protected function _getCacheId() {
        //return 'CONTAINER_HEADER_' . md5($this->_placeholder->getAttribute('cache_id') . $this->_placeholder->getAttribute('cart_count') ) . '_' . $this->_getIdentifier();
        return 'CONTAINER_HEADER_' . md5( $this->_placeholder->getAttribute('cache_id') . $this->_getIdentifier() );
    }

    protected function _renderBlock() {
        $blockClass = $this->_placeholder->getAttribute('block');
        $template = $this->_placeholder->getAttribute('template');

        $block = new $blockClass;
        $block->setTemplate($template);
        return $block->toHtml();
    }

}
Run Code Online (Sandbox Code Playgroud)

我从Magento上的挖孔线程中读到的内容是我在FPC缓存服务请求时没有初始化Mage应用程序,所以基本上添加占位符属性的方法不起作用,因为Mage::helper( 'checkout/cart' )->getCart()->getItemsCount();不起作用,对吧?

即使它应该如何,但它似乎根本没有运行,就像我die()在那里打了电话但没有发生任何事情.

那么我错过了什么?我如何检索购物车项目数量,以便它可用于构建缓存ID?

进展:我发现Enterprise_PageCache_Model_Cookie::COOKIE_CART但这只会在购物车更新后发生变化.之后它保持不变.这很奇怪,这感觉就像解决方案,但其行为却说不然.

在会话中我找不到购物车项目数.因此,我目前看到这样做的唯一方法是在更新时将购物车数量保存在会话中,然后使用它_getIdentifier().

我发现观察者对于购物车是不一致的.另外,更新事件是为了调度,但是为了删除,它不会.所以我想我可以添加我的观察者以某种方式对报价的价格更新,如果这与观察者一致吗?

有什么建议?

Zif*_*ius 0

请参阅我的类似问题:购物车上的整页缓存失效(报价)更改

我放弃了实现,因为在我的情况下这是不可能的,但我会Enterprise_PageCache_Model_Container_Advanced_Quote进一步深入研究,因为它似乎被购物车块用来刷新自身,以防报价内容发生变化