0

我需要删除默认 Magento 结帐并添加自定义。问题是自定义扩展模板未加载。日志没有显示任何错误。我附上了截图http://skit.ch/nwpi

代码在这里https://gist.github.com/3636029

这里有两个问题,

块不渲染?

即使我取消了设置"checkout.onepage",当我转储整个布局时,它也会显示默认的结帐布局代码。这是正常行为吗?

4

1 回答 1

2

问题在于您的控制器:

$this->getLayout()->getBlock('content')->unsetChildren('checkout.onepage');

看:

Mage_Core_Block_Abstract

/**
 * Unset all children blocks
 *
 * @return Mage_Core_Block_Abstract
 */
public function unsetChildren()
{
    $this->_children       = array();
    $this->_sortedChildren = array();
    return $this;
}

/**
 * Unset child block
 *
 * @param  string $alias
 * @return Mage_Core_Block_Abstract
 */
public function unsetChild($alias)
{
    if (isset($this->_children[$alias])) {
        unset($this->_children[$alias]);
    }

    if (!empty($this->_sortedChildren)) {
        $key = array_search($alias, $this->_sortedChildren);
        if ($key !== false) {
            unset($this->_sortedChildren[$key]);
        }
    }

    return $this;
}

所以你的代码应该是:

$this->getLayout()->getBlock('checkout.onepage')->unsetChildren();

或者

$this->getLayout()->getBlock('content')->unsetChild('checkout.onepage');

于 2012-09-06T16:07:26.067 回答