【问题标题】:Magento Enterprise Full Page Cache(FPC) Cart Sidebar issue when Switching between Multiple currencies在多种货币之间切换时,Magento Enterprise 整页缓存(FPC)购物车侧边栏问题
【发布时间】:2014-08-20 20:00:46
【问题描述】:

问题:

如果您的 magento 企业商店启用了多种货币,并且您正在使用购物车侧边栏快速概览购物车中的商品:当客户尝试在货币之间切换时,整页缓存将成为一个恶棍。购物车侧边栏不会根据切换的货币进行更新。

【问题讨论】:

    标签: php hole-punching magento-fpc


    【解决方案1】:

    我已将答案发布在 http://www.eglobeits.com/blog/magento/magento-enterprise-edition-full-page-cache-mutli-currencies-mini-cart-sidebar-issue-when-switching-currencies/, 但在下面添加相同的内容以供您快速参考。

    解决方法: 重新定义 Cart Side Place holder 容器并定义一个新的缓存 Id 生成器,而不是使用 fpc 原来的那个。

    按照以下步骤操作:

    1.使用以下内容创建 app/code/local/Egits/PageCache/etc/config.xml

       <?xml version="1.0"?>
       <config>
           <modules>
               <Egits_PageCache>
                   <version>0.0.1</version>
               </Egits_PageCache>
           </modules>
        </config>
    

    2。使用以下内容创建 app/code/etc/modules/Egits_PageCache.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <config>
        <modules>
            <Egits_PageCache>
                <active>true</active>
                <codePool>local</codePool>
                <depends>
                    <Enterprise_PageCache />
                </depends>
            </Egits_PageCache>
        </modules>
    </config>
    

    3.使用以下内容创建 app/code/local/Egits/PageCache/etc/cache.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <config>
        <placeholders>
            <cart_sidebar>
                <block>checkout/cart_sidebar</block>
                <placeholder>CART_SIDEBAR</placeholder>
                <container>Egits_PageCache_Model_Container_Sidebar_Cart</container>
                <cache_lifetime>86400</cache_lifetime>
            </cart_sidebar>
        </placeholders>
    </config>
    

    4.使用以下内容创建 app/code/local/Egits/PageCache/Model/Container/Sidebar/Cart.php

    <?php
    
    class Egits_PageCache_Model_Container_Sidebar_Cart extends Enterprise_PageCache_Model_Container_Sidebar_Cart
    {
        const CURRENCY_COOKIE = 'currency';
    
        /**
          * Get cache id for the block
          * @return string
          */
        protected function _getCacheId()
        {
            $cookieCart = Enterprise_PageCache_Model_Cookie::COOKIE_CART;
            $cookieCustomer = Enterprise_PageCache_Model_Cookie::COOKIE_CUSTOMER;
            $curreny = array_key_exists(self::CURRENCY_COOKIE, $_COOKIE) ? $_COOKIE[self::CURRENCY_COOKIE] : '';
            return md5(
                Enterprise_PageCache_Model_Container_Advanced_Quote::CACHE_TAG_PREFIX
                . (array_key_exists($cookieCart, $_COOKIE) ? $_COOKIE[$cookieCart] : '')
                . (array_key_exists($cookieCustomer, $_COOKIE) ? $_COOKIE[$cookieCustomer] : '')
                . $curreny
            );
        }
    
    }
    

    4.刷新所有缓存,您就完成了! :).. 很简单...嗯??

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-22
      • 1970-01-01
      • 1970-01-01
      • 2015-02-21
      相关资源
      最近更新 更多