Magento Enterprise Edition Full Page Cache, Mutli Currencies Mini Cart Sidebar Issue when Switching Currencies

Magento Enterprise Edition Full Page Cache, Mutli Currencies Mini Cart Sidebar Issue when Switching Currencies

Magento Enterprise Edition Full Page Cache, Mutli Currencies Mini Cart Sidebar Issue when Switching Currencies
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 villian when the customer try to switch between currencies. The Cart Sidebar won't get updated based on the currency switched. The Cause: This issue is coming out of the box magento Enterprise Full page Cache :). The exact reason for this is, Magento is not considering the customer's currency before generating the cache Id. For The cart Side bar as well, magento Uses default FPC cache Id generating Function. The Fix: Redefine the Cart Side Placeholder 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
    
    
        
            
                0.0.1
            
        
    
2. Create app/code/etc/modules/Egits_PageCache.xml wih following content
    
    
        
            
                true
                local
                
                    
                
            
        
    
3. Create app/code/local/Egits/PageCache/etc/cache.xml wih following content
    
    
        
            
                checkout/cart_sidebar
                CART_SIDEBAR
                Egits_PageCache_Model_Container_Sidebar_Cart
                86400
            
        
    
4. Create app/code/local/Egits/PageCache/Model/Container/Sidebar/Cart.php with following content
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);
    }

}
Flush All your caches and you are done! :).. Pretty Simple... ehhh??

  • Share on Facebook
  • Share on Twitter
  • Share on LinkedIn

leave a comment