के माध्यम से गतिशील सामग्री छेद-पेंच प्राप्त करने का प्रयास कर रहा हूं मैं Magento Enterprise 1.10.1.1 का उपयोग कर रहा हूं और हमारे उत्पाद पृष्ठों पर कुछ गतिशील सामग्री प्राप्त करने की आवश्यकता है। मैं एक ब्लॉक में वर्तमान समय को तुरंत देख रहा हूं कि यह काम कर रहा है या नहीं, लेकिन पूर्ण पृष्ठ कैश के माध्यम से नहीं लग रहा है।Magento के पूर्ण पृष्ठ कैश
मैं यहां पाया कार्यान्वयन की एक किस्म की कोशिश की है:
http://tweetorials.tumblr.com/post/10160075026/ee-full-page-cache-hole-punching http://oggettoweb.com/blog/customizations-compatible-magento-full-page-cache/ http://magentophp.blogspot.com/2011/02/magento-enterprise-full-page-caching.html
किसी भी समाधान, विचार, टिप्पणियाँ, सलाह का स्वागत है।
एप्लिकेशन/कोड/स्थानीय/Fido/उदाहरण/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Fido_Example>
<version>0.1.0</version>
</Fido_Example>
</modules>
<global>
<blocks>
<fido_example>
<class>Fido_Example_Block</class>
</fido_example>
</blocks>
</global>
</config>
एप्लिकेशन/कोड/स्थानीय/Fido/उदाहरण/etc/cache.xml:
यहाँ मेरी कोड है
<?xml version="1.0" encoding="UTF-8"?>
<config>
<placeholders>
<fido_example>
<block>fido_example/view</block>
<name>example</name>
<placeholder>CACHE_TEST</placeholder>
<container>Fido_Example_Model_Container_Cachetest</container>
<cache_lifetime>86400</cache_lifetime>
</fido_example>
</placeholders>
</config>
एप्लिकेशन/कोड/स्थानीय/Fido/उदाहरण/ब्लॉक/View.php
<?php
class Fido_Example_Block_View extends Mage_Core_Block_Template
{
private $message;
private $att;
protected function createMessage($msg) {
$this->message = $msg;
}
public function receiveMessage() {
if($this->message != '') {
return $this->message;
}
else {
$this->createMessage('Hello World');
return $this->message;
}
}
protected function _toHtml() {
$html = parent::_toHtml();
if($this->att = $this->getMyCustom() && $this->getMyCustom() != '') {
$html .= '<br />'.$this->att;
}
else {
$now = date('m-d-Y h:i:s A');
$html .= $now;
$html .= '<br />' ;
}
return $html;
}
}
एप्लिकेशन/कोड/स्थानीय/Fido/उदाहरण/मॉडल/कंटेनर/Cachetest.php
<?php
class Fido_Example_Model_Container_Cachetest extends Enterprise_PageCache_Model_Container_Abstract {
protected function _getCacheId()
{
return 'HOMEPAGE_PRODUCTS' . 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();
}
protected function _saveCache($data, $id, $tags = array(), $lifetime = null) { return false; }
}
एप्लिकेशन/डिजाइन/दृश्यपटल/उद्यम/[mytheme] /template/example/view.phtml
<?php echo $this->receiveMessage() ?>
एप्लिकेशन/डिजाइन/दृश्यपटल/उद्यम से
टुकड़ा/[mytheme] /layout/catalog.xml
<reference name="content">
<block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">
<block type="fido_example/view" name="product.info.example" as="example" template="example/view.phtml" />
आपने 'Fido_Example_Model_Container_Cachetest :: _ getIdentifier()' का कोड नहीं दिखाया। यदि आप [http://oggettoweb.com/blog/customizations-compatible-magento-full-page-cache/] अच्छी तरह से पढ़ते हैं, तो आपको पता चलेगा कि छेद पंचिंग के साथ ब्लॉक का आउटपुट भी कैश किया गया है। उदाहरण के लिए [http://oggettoweb.com/blog/customizations-compatible-magento-full-page-cache/] पर यह प्रत्येक ग्राहक के लिए कैश किया गया है। आप इसे अद्वितीय बनाने के लिए '_getIdentifier() 'से कुछ' microtime()' या कुछ ऐसा करने का प्रयास कर सकते हैं। यकीन नहीं है कि यह विचार अच्छा है हालांकि। – Zyava
सलाह जियावा के लिए धन्यवाद, लेकिन उसने चाल नहीं की - अभी भी कैश हो रही है। (Btw, मैं भूलवश निकाल दिया कि Cachetest.php – rlflow
से आप वाकई ' 'HOMEPAGE_PRODUCTS' हैं md5 ($ इस -।> _ Placeholder-> getAttribute ('cache_id') $ इस -।> _ एक नया मान getIdentifier())' हमेशा होता है ? – Zyava