I am trying to override this file :-


i call this file in my di.xml Here is xml code


  <?xml version="1.0"?>
   <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
   <preference for="Magento\Sales\Block\Order\Email\Items\DefaultItems" type="Vendor\Module\Block\Order\Email\Items\DefaultItems" />

On following path i have create DefaultItems.php


Here is code of DefaultItems.php


namespace Vendor\Module\Block\Order\Email\Items;

use \Magento\Sales\Model\Order\Creditmemo\Item as CreditmemoItem;
use \Magento\Sales\Model\Order\Invoice\Item as InvoiceItem;
use \Magento\Sales\Model\Order\Item as OrderItem;

 * Sales Order Email items default renderer
 * @author     Magento Core Team <[email protected]>
class DefaultItems extends \Magento\Sales\Block\Order\Email\Items\DefaultItems
    public function getAdditionalOptionData()

        return "hello";


In this file


I have write following code

echo $block->getAdditionalOptionData(); die;

Now, when i send invoice email from admin, my code is not working. It should display hello.

When i put di.xml file code in comment and add function getAdditionalOptionData in magento vendor file, hello display.

I am using magento 2.1.6

Can anyone please let me know where i make mistake?

  • 1
    Firstly check whether your module is enabled or not and remove generated and flush cache Commented Apr 3, 2019 at 11:59
  • Remove from slash (\) at use \Magento\Sales\Model\Order\Creditmemo\Item as CreditmemoItem; use \Magento\Sales\Model\Order\Invoice\Item as InvoiceItem; use \Magento\Sales\Model\Order\Item as OrderItem;
    – Amit Bera
    Commented Apr 3, 2019 at 13:13
  • why you need to override the class
    – Amit Bera
    Commented Apr 3, 2019 at 13:16
  • @PrathapGunasekaran I already did that. But not working.
    – user55548
    Commented Apr 3, 2019 at 13:23
  • @AmitBera I want to add additional information in invoice email. When invoice mail sent first time, additional data comes properly. But when i send mail again, at that time additional data not comes. That's why i want to override.
    – user55548
    Commented Apr 3, 2019 at 13:25

1 Answer 1


After R&D I found solution. I hope this will help to someone.

I have add default.phtml file into my module instead of theme So now, new path is



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.