我需要将2个块链接到一个模板,但是,我声明了这种布局:
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<referenceContainer name="content">
<block class="Magento\Checkout\Block\Cart" name="checkout1" template="Company_Checkout::index.phtml" />
<block class="Magento\Contact\Block\ContactForm" name="checkout2" template="Company_Checkout::index.phtml" />
</referenceContainer>
</page>
但是当我尝试在模板中访问这样的checkout1块方法时:
<h2>Welcome</h2>
<?php
$items = $block->getItems();
foreach ($items as $object) {
var_dump($object->debug());
}
?>
我遇到此错误:
1个异常:异常#0(异常):警告:无效的参数 提供给foreach() /var/www/html/app/code/Company/Checkout/view/frontend/templates/index.phtml 在第4行
有人可以帮助我吗?