doudi1979 2014-06-30 12:34
浏览 33
已采纳

在多种货币之间切换时,Magento Enterprise全页缓存(FPC)购物车边栏问题

The Issue:

If your magento enterprise store has multiple currencies enabled and you are using Cart Sidebar to give a quick overview of items in the cart: Full Page Cache will be a villain when the customer try to switch between currencies. The Cart Sidebar won't get updated based on the currency switched.

  • 写回答

1条回答 默认 最新

  • duadlkc5762218 2014-06-30 12:34
    关注

    I have published the answer at http://www.eglobeits.com/blog/magento/magento-enterprise-edition-full-page-cache-mutli-currencies-mini-cart-sidebar-issue-when-switching-currencies/, but Adding the same below for your quick reference.

    The Fix: Redefine the Cart Side Place holder container and define a new cache Id generator rather than Using fpc's original one.

    Follow below Steps:

    1. Create app/code/local/Egits/PageCache/etc/config.xml with following content

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

    2. Create app/code/etc/modules/Egits_PageCache.xml wih following content

    <?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. Create app/code/local/Egits/PageCache/etc/cache.xml wih following content

    <?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. Create app/code/local/Egits/PageCache/Model/Container/Sidebar/Cart.php with following content

    <?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. Flush All your caches and you are done! :).. Pretty Simple... ehhh??

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?