Magento 2 - Remove debug path hint from email template

Magento Asked by Hardik on December 9, 2020

I am sending order email from my custom module. Issue is in order email it showing debug path hint. Here is the code that i am using.

public function sendEmail($orderdata, $order)

   /*Send email*/
    $storeScope = MagentoStoreModelScopeInterface::SCOPE_STORE;
    $sender = [
        //'name' => $this->_escaper->escapeHtml($customer->getFirstName()),
        //'email' => $this->_escaper->escapeHtml($customer->getEmail()),
        'name' => 'My store',
        'email' => $this->scopeConfig->getValue('trans_email/ident_general/email', $storeScope)
    $postObject = new MagentoFrameworkDataObject();

    $transport = $this->_transportBuilder
            ->setTemplateIdentifier('7') // Send the ID of Email template which is created in Admin panel
                        'area' => MagentoFrameworkAppArea::AREA_FRONTEND,
                        'store' => $this->storeManager->getStore()->getId()
            ->setTemplateVars(['order' => $order, 'manufacturerdata' => $orderdata,  'billingaddress' => $orderdata['billingaddress'], 'shippingaddress' => $orderdata['shippingaddress']])

    /**********End Send email*/


<?xml version="1.0"?>
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
<page xmlns:xsi="" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd" label="Email Order Items List" design_abstraction="custom">
    <update handle="manufactures_email_order_renderers"/>
    <!--<update handle="sales_email_item_price"/>-->
        <block class="MagentoSalesBlockOrderEmailItems" name="items" template="HK_OrderEmail::email/manufacturer_items.phtml" cacheable="false">
            <block class="MagentoFrameworkViewElementRendererList" name="" as="renderer.list"/>
            <!--<block class="MagentoSalesBlockOrderTotals" name="order_totals" template="Magento_Sales::order/totals.phtml">
                    <argument name="label_properties" xsi:type="string">colspan="2"</argument>
                <block class="MagentoTaxBlockSalesOrderTax" name="tax" template="Magento_Tax::order/tax.phtml">
                    <action method="setIsPlaneMode">
                        <argument name="value" xsi:type="string">1</argument>
        <block class="MagentoFrameworkViewElementTemplate" name="" template="Magento_Theme::template.phtml"/>


<?xml version="1.0"?>
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
<page xmlns:xsi="" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd" label="Email Creditmemo Items List" design_abstraction="custom">
        <referenceBlock name="">
            <block class="MagentoSalesBlockOrderEmailItemsOrderDefaultOrder" as="default" template="HK_OrderEmail::email/items/order/default.phtml"/>

Order email template.

{{template config_path="design/email/header_template"}}

    <tr class="email-information">
            <table class="order-details">
                    <td class="address-details">
                        <h3>{{trans "Billing Info"}}</h3>
                        <p>{{var billingaddress|raw}}</p>
                    {{depend order.getIsNotVirtual()}}
                    <td class="address-details">
                        <h3>{{trans "Shipping Info"}}</h3>
                        <p>{{var shippingaddress|raw}}</p>
            {{layout handle="manufacturer_email_order_items" order=$order manufacturerdata=$manufacturerdata area="frontend"}}

{{template config_path="design/email/footer_template"}}

Here is the email that i am getting with path hint. Path hint is already disabled. I have double checked in DB and also removed cache as well.
enter image description here

3 Answers

I had similar issue when sending email through command in Maganeto 2. To solve this in your custom module di.xml file add this

  • app/code/NameSpace/Module/etc/di.xml

    <type name="MagentoDeveloperModelTemplateEnginePluginDebugHints">
            <argument name="debugHintsPath" xsi:type="string">dev/debug/template_hints_storefront</argument>

Tested in magento 2.2.5.

Answered by on December 9, 2020

i had the same problem, but in a command. So Alex' solution does not work this way for me, but i could solve this the following way. I hope i could help someone with the code.

I was searching the half day for a solution and i posted the answer also in another thread. but the threads were in significally different search terms in google, so i hope someone will find at least one of the solutions described.

public function __construct(MagentoStoreModelStoreManagerInterface $storeManager,
                            MagentoFrameworkObjectManagerInterface $objectManager,
                            MagentoFrameworkObjectManagerConfigLoaderInterface $configLoader,
                            MagentoFrameworkAppAreaList $areaList) {

        $this->storeManager = $storeManager;
        $this->objectManager = $objectManager;
        $this->configLoader = $configLoader;
        $this->areaList = $areaList;



public function init() {


        $localeInterface = $this->objectManager->create('MagentoFrameworkTranslateInterface');

        $areaObject = $this->areaList->getArea(MagentoFrameworkAppArea::AREA_ADMINHTML);


My problem was that i had the email debug path inside the mails. This is caused by magento itself, because magento won´t set any store view or load languages or translations in a cron / command. So you need to set it by yourself.

We have 1 location of sending an email - when creating a shipment - and here it works like a charm. The email looks - like it should - the same like if i would create a shipment in the backend manually.

It is a shame for magento that there is no "preloading" of translations, store views or helper functions for commands, like setting the language / store view.

Answered by Chris Schrut on December 9, 2020

I found the problem. When you try to send email by cron, it take by default configs from adminhtml. By default in adminhtml debug email path is always enabled. I use the next functionality for set front area and prevent the problem.


     namespace Your_NamespaceCron;

     use MagentoFrameworkAppConfigScopeConfigInterface;
     use MagentoFrameworkAppArea;
     use MagentoFrameworkAppState as AppState;
     use MagentoFrameworkObjectManagerInterface;
     use MagentoFrameworkObjectManagerConfigLoaderInterface;

      * Class SendMail
      * @packageYour_NamespaceCron
     class SendMail
          public function execute($options, OutputInterface $output)
             try  {
                   [$this, "executeCallBack"],
                   [$options, $output]
             } catch (Exception $e) {

          public function executeCallBack($options, OutputInterface $output)
              // your main functionality

Answered by Alexander Talda on December 9, 2020

Add your own answers!

Related Questions

Get matrixrate config programatically

0  Asked on December 14, 2020 by pevik


Error 404 : The requested page do not exist

1  Asked on December 14, 2020 by claims


Magento 2 Checkout shipping afterRender

0  Asked on December 13, 2020 by mac_mod


How to make checkout page 2columns-left on magento 2

1  Asked on December 13, 2020 by alin-lupoiu


magento2 plugin and str_replace

2  Asked on December 11, 2020 by boll


Custom email layout handle for custom module

2  Asked on December 11, 2020 by karan-adhikari


Magento 2 – Remove debug path hint from email template

3  Asked on December 9, 2020 by hardik


Watermark magento 2

2  Asked on December 9, 2020 by pascal-van-kooten


How to place sizes in order

1  Asked on December 7, 2020 by stefaniiia


Magento 2.4 disable UI/Theme part

0  Asked on December 7, 2020 by bogdan-hepting


Ask a Question

Get help from others!

© 2022 All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP