2013-04-30 7 views
5

के साथ Magento मल्टी लैगेज स्टोर वर्निश के साथ बहु-भाषा Magento स्टोर कैसे काम करता है। क्या वार्निश में कोई विन्यास उपलब्ध है, इसलिए हम कुकीज़ पर कैश बेस बना सकते हैं?वार्निश

उत्तर

5

आप अलग अलग यूआरएल पर किया जा रहा है भाषाओं कोई आपत्ति नहीं है, तारपीन आप के लिए इस संभाल कर सकते हैं: https://github.com/nexcess/magento-turpentine/issues/36

आप उन्हें के रूप में व्यवहार करना चाहते हैं वे बॉक्स से बाहर करते हैं, चलते रहते हैं। https://www.varnish-cache.org/trac/wiki/VCLExampleCachingLoggedInUsers

हम इस संशोधित को भी ध्यान में दुकान कुकी कि भाषा चयनकर्ता के आधार पर Magento सेट लेने के लिए होगा:

आप संशोधित करने के लिए कैसे वार्निश उत्पन्न करता है अपने VCL संदर्भ में है की है। (यहां व्यवहार के बाद: http://demo.magentocommerce.com) दुर्भाग्यवश यह मुश्किल हो जाता है क्योंकि वार्निश या तो सर्वर पर वापस कुकीज़ को पास नहीं करता है या जब यह

पर कुकीज के मूल्य पर आधारित वार्निश कैश होगा साथ ही डिफ़ॉल्ट यूआरएल और मेजबान के रूप में:

sub vcl_hash { 
     hash_data(req.url); 
     hash_data(req.http.host); 

     if (req.http.Cookie ~ "(?:^|;\s*)(?:store=(.*?))(?:;|$)"){ 
       hash_data(regsub(req.http.Cookie, "(?:^|;\s*)(?:store=(.*?))(?:;|$)")); 
     } 

     return (hash); 
} 

लेकिन, इस विधि के साथ आप अपने VCL के बाकी बदलाव करने पेज को ठीक तरह संचय और कुकी सर्वर

एक अन्य विकल्प के लिए वापस भेजने के लिए हो सकता है एक मनमानी शीर्षलेख पर कैशिंग को अलग करने के लिए कुकी का उपयोग करना है, इसे एक्स-मैज-एल कहते हैं आंग:

sub vcl_fetch { 
    #can do this better with regex 
    if (req.http.Cookie ~ "(?:^|;\s*)(?:store=(.*?))(?:;|$)"){ 
     if (!beresp.http.Vary) { # no Vary at all 
      set beresp.http.Vary = "X-Mage-Lang"; 
     } elseif (beresp.http.Vary !~ "X-Mage-Lang") { # add to existing Vary 
      set beresp.http.Vary = beresp.http.Vary + ", X-Mage-Lang"; 
     } 
    } 
    # comment this out if you don't want the client to know your classification 
    set beresp.http.X-Mage-Lang = regsub(req.http.Cookie, "(?:^|;\s*)(?:store=(.*?))(?:;|$)"); 
} 

यह पैटर्न भी वार्निश के साथ डिवाइस का पता लगाने के लिए प्रयोग किया जाता है: https://github.com/varnish/varnish-devicedetect/blob/master/INSTALL.rst

उसके बाद, आप Mage_Core_Model_App विस्तार करने के लिए 'दुकान' कुकी के बजाय इस शीर्षक का प्रयोग करना होगा। Magento सीई 1.7 इसके _checkCookieStore में:

protected function _checkCookieStore($type) 
{ 
    if (!$this->getCookie()->get()) { 
     return $this; 
    } 

    $store = $this->getCookie()->get(Mage_Core_Model_Store::COOKIE_NAME); 
    if ($store && isset($this->_stores[$store]) 
     && $this->_stores[$store]->getId() 
     && $this->_stores[$store]->getIsActive()) { 
     if ($type == 'website' 
      && $this->_stores[$store]->getWebsiteId() == $this->_stores[$this->_currentStore]->getWebsiteId()) { 
      $this->_currentStore = $store; 
     } 
     if ($type == 'group' 
      && $this->_stores[$store]->getGroupId() == $this->_stores[$this->_currentStore]->getGroupId()) { 
      $this->_currentStore = $store; 
     } 
     if ($type == 'store') { 
      $this->_currentStore = $store; 
     } 
    } 
    return $this; 
} 

आप $ _SERVER '[' एक्स-दाना-लैंग '] कुकी

+0

कुकी समाधान कैशिंग का उपयोग केवल एक उपयोगकर्ता पर लागू होगा। –

+0

यह सत्र कुकी नहीं है, यह कुकी के मूल्य को ट्रिगर कर रहा है जिसमें इसकी भाषा – timbroder

+0

ठीक है, मेरी गलती। अच्छा अवलोकन अवलोकन। –

1

जोड़ें वार्निश कॉन्फ़िग में लाइनों के बाद,

if(beresp.http.Set-Cookie) { 
    return (hit_for_pass); 
} 
+0

क्या इन पंक्तियों का असर है के बजाय पर वर्तमान स्टोर स्थापित करेगा? क्या यह सबसे अच्छा या सिर्फ सबसे छोटा जवाब है? ;) – fbtb

संबंधित मुद्दे