I am trying to override the getValueHtml function inside Magento\Bundle\Block\Sales\Order\Items\Renderer. When I test this in my order emails it results in the entire item block being empty. What gives?
I've got my module setup and inside di.xml I've got:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
<preference for="Magento\Bundle\Block\Sales\Order\Items\Renderer" type="Vendor\Module\Block\Sales\Order\Items\Renderer" />
</config>
Then under app/code/Vendore/Module/Block/Sales/Order/Items/Renderer.php I have:
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Vendor\Module\Block\Sales\Order\Items;
/**
* Order item render block
*
* @author Magento Core Team <[email protected]>
*/
class Renderer extends \Magento\Bundle\Block\Sales\Order\Items\Renderer
{
/**
* @param mixed $item
* @return string
*/
public function getValueHtml($item)
{
if ($attributes = $this->getSelectionAttributes($item)) {
if($attributes['qty'] == 1) {
return $this->escapeHtml($item->getName());
} else {
return sprintf('%d', $attributes['qty']) . 'x ' . $this->escapeHtml($item->getName());
}
} else {
return $this->escapeHtml($item->getName());
}
}
}