I am receiving error when I use plugin to modify Invoice Items template.
Exception #0 (RuntimeException): Renderer list for block "sales.order.invoice" is not defined
This seems like a weird bug, I tried to add sequence in module.xml for Magento_Sales, but still gives the error.
Is there a better way to override this template file?
In my \Vendor\Module\etc\frontend\di.xml
<type name="Magento\Sales\Block\Order\Invoice\Items">
<plugin name="vendor_module_sales_order_invoice_items" type="Vendor\Module\Plugin\Sales\Order\Invoice\Items" />
</type>
My plugin file \Vendor\Module\Plugin\Sales\Order\Invoice\Items.php
<?php
namespace Vendor\Module\Plugin\Sales\Order\Invoice;
use Vendor\Module\Helper\Data as Helper;
class Items
{
protected $_helper;
public function __construct(
Helper $_helper
)
{
$this->_helper = $_helper;
}
public function beforeToHtml($subject)
{
if(!$this->_helper->isEnabled()) {
return;
}
$subject->setTemplate("Vendor_Module::sales/order/invoice/items.phtml");
return;
}
}
Has anyone else encountered this? And is there a better way to workaround this problem? I am using Magento version 2.3.1.