简体   繁体   English

在magento中从控制器加载块,缓存问题?

[英]Loading a block from a controller in magento, cache issue?

I have two methods inside my controller i call to get html for various ajax updates. 我在控制器中调用了两种方法来获取各种Ajax更新的html。

    protected function _getDemoShippingMethodsHtml()
    {
        $layout = $this->getLayout();
        $update = $layout->getUpdate();
        $update->load('checkout_onepage_demoshippingmethod');
        $layout->generateXml();
        $layout->generateBlocks();
        $output = $layout->getOutput();

        return $output;
    }

    protected function _getSelectedDealerHtml()
    {
        $layout = $this->getLayout();
        $update = $layout->getUpdate();
        $update->load('checkout_onepage_selecteddealer');
        $layout->generateXml();
        $layout->generateBlocks();
        $output = $layout->getOutput();

        return $output;
    }

During one request to my controller if i call only one of these methods it loads the block as expected. 在对控制器的一个请求中,如果我仅调用这些方法之一,它将按预期加载该块。 The problem comes in where i try to call both of these function during one request. 问题出在我试图在一个请求中同时调用这两个函数的地方。 Which ever method is called first outputs the expected html, and the second method call outputs the exact same html as the first. 哪个方法被调用,第一个方法输出期望的html,第二个方法调用输出与第一个完全相同的html。

在使用的块类中,创建一个空的伪构造函数受保护的函数_construct(){}

try use clean cache programatically Mage::app()->cleanCache(); 尝试以编程方式使用干净的缓存Mage :: app()-> cleanCache();

Clear Magento cache 清除Magento缓存

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM