Fix layout.xml caching causing blocks to render other blocks in Magento

来源:互联网 发布:淘宝 确认收货 换货 编辑:程序博客网 时间:2024/05/06 12:52

http://davemacaulay.com/fix-layout-xml-caching-causing-blocks-render-blocks-magento/

缓存开启后 在付款页面 点击 next无法继续

If you’re building a system which uses Ajax and makes numerous calls to $this->getLayout()->getUpdate()->load() (which enables you to load sections of the layout.xml file) and render these all on the same page you’ll come across an error where the blocks all render as the first block in the call. This is due to the way the cache id’s work against these blocks.

You can see this functionality used within the checkout such as in the _getShippingMethodsHtml() withinOnepageController.php function:

To overcome this issue you’ll need to manually set the cache ids at the top of every call to load() like the following:

This will make sure the layout caching knows that this block is different from any others called on the same page.

So for instance in the code example above you could change the function code to read the following and avoid any caching issues. You’ll need to add custom cache ids into all calls to $this->getLayout()->getUpdate()->load():


0 0
原创粉丝点击