ฉันคิดว่าวิธีที่เหมาะสมคือเราต้องสร้างโมดูลแบบกำหนดเองเพราะคุณทุกคนรู้ว่า Magento Boogieman จะให้คุณ! ถ้าเปลี่ยนแกน :)
คุณจะต้องมีไฟล์ดังต่อไปนี้: app/etc/modules/Bhupendra_Cms.xml
<?xml version="1.0"?>
<config>
<modules>
<Bhupendra_Cms>
<active>true</active>
<codePool>local</codePool>
<depends>
<Mage_Cms/>
</depends>
</Bhupendra_Cms>
</modules>
</config>
app/code/local/Bhupendra/Cms/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Bhupendra_Cms>
<version>1.0.0</version>
</Bhupendra_Cms>
</modules>
<global>
<blocks>
<cms>
<rewrite>
<block>Bhupendra_Cms_Block_Block</block>
<widget_block>Bhupendra_Cms_Block_Widget_Block</widget_block>
</rewrite>
</cms>
</blocks>
</global>
</config>
app/code/local/Bhupendra/Cms/Block/Block.php
<?php
class Bhupendra_Cms_Block_Block extends Mage_Cms_Block_Block {
public function getCacheKeyInfo()
{
$blockId = $this->getBlockId();
if ($blockId) {
$result = array(
$blockId,
Mage::app()->getStore()->getCode(),
);
} else {
$result = parent::getCacheKeyInfo();
}
return $result;
}
}
app/code/local/Bhupendra/Cms/Block/Widget/Block.php
class Bhupendra_Cms_Block_Widget_Block extends Mage_Cms_Block_Widget_Block
{
/**
* Storage for used widgets
*
* @var array
*/
static protected $_widgetUsageMap = array();
/**
* Prepare block text and determine whether block output enabled or not
* Prevent blocks recursion if needed
*
* @return Mage_Cms_Block_Widget_Block
*/
protected function _beforeToHtml()
{
parent::_beforeToHtml();
$blockId = $this->getData('block_id');
$blockHash = get_class($this) . $blockId;
if (isset(self::$_widgetUsageMap[$blockHash])) {
return $this;
}
self::$_widgetUsageMap[$blockHash] = true;
if ($blockId) {
$block = Mage::getModel('cms/block')
->setStoreId(Mage::app()->getStore()->getId())
->load($blockId);
if ($block->getIsActive()) {
/* @var $helper Mage_Cms_Helper_Data */
$helper = Mage::helper('cms');
$processor = $helper->getBlockTemplateProcessor();
$this->setText($processor->filter($block->getContent()));
$this->addModelTags($block);
}
}
unset(self::$_widgetUsageMap[$blockHash]);
return $this;
}
/**
* Retrieve values of properties that unambiguously identify unique content
*
* @return array
*/
public function getCacheKeyInfo()
{
$result = parent::getCacheKeyInfo();
$blockId = $this->getBlockId();
if ($blockId) {
$result[] = $blockId;
}
return $result;
}
}
สำหรับข้อมูลเพิ่มเติมคุณสามารถเยี่ยมชมบล็อกต่อไปนี้และคุณสามารถดาวน์โหลดได้จาก
https://www.milople.com/blogs/ecommerce/solved-magento-static-block-display-issue.html