3

I am developing a little custom Magento 2 extension that sends emails to admins on certain events.

In layout handle's phtml template file I originally made a spelling mistake, which when corrected doesn't show at all ( no change to the phtml file have any effect)

Template file (view/frontend/email/low_stock_email.html)

<!--@subject Low Stock Notification  @-->
{{template config_path="design/email/header_template"}}
<h1>The following products are low or out of stock</h1>
<table style="width: 100%; ">
    <tr>{{layout handle="low_stock_email_items" items=$items area="frontend"}}</tr>
    <tr>Thank you!</tr>
</table>
{{template config_path="design/email/footer_template"}}

Layout XML (view/frontend/layout/low_stock_email_items.xml)

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd" label="Review Remind Email Order Items List" design_abstraction="custom">
    <body>
        <block class="Hapex\AdminEmailNotifications\Block\Email\Items" name="items" template="Hapex_AdminEmailNotifications::email/items_low_stock.phtml" cacheable="false"></block>
    </body>
</page>

Old template phtml file (view/frontend/templates/email/items_low_stock.phtml)

<?php
$products = $block->getItems();
?>

<?php if(is_array($products)): ?>

    <table id="hapex-products" style="border: 1px solid #bcbcbc;width:100%">
        <tr>
            <th style="padding: 10px;">Name Product</th>
            <th style="padding: 10px;">SKU</th>
        </tr>

        <?php foreach($products as $product) :?>
            <tr>
                <td style="padding: 10px;font-size: 12px;font-style: italic;"><?php echo $product['name'];?></td>
                <td style="padding: 10px;font-size: 12px;font-style: italic;"><?php echo $product['sku'];?></td>
            </tr>
        <?php endforeach;?>

    </table>

<?php endif;?>

Updated one (view/frontend/templates/email/items_low_stock.phtml)

<?php
$products = $block->getItems();
?>

<?php if(is_array($products)): ?>

    <table id="hapex-products" style="border: 1px solid #bcbcbc;width:100%">
        <tr>
            <th style="padding: 10px;">Product Name</th>
            <th style="padding: 10px;">SKU</th>
        </tr>

        <?php foreach($products as $product) :?>
            <tr>
                <td style="padding: 10px;font-size: 12px;font-style: italic;"><?php echo $product['name'];?></td>
                <td style="padding: 10px;font-size: 12px;font-style: italic;"><?php echo $product['sku'];?></td>
            </tr>
        <?php endforeach;?>

    </table>

<?php endif;?>

Emails still show the spelling mistake

enter image description here

1 Answer 1

0

Need to clear generated folder

rm -rf var/cache/ var/view_preprocessed/ generated/
php bin/magento setup:static-content:deploy -f
8
  • Did you try this? Commented Jul 8, 2019 at 10:02
  • Just did and it is still the same :(
    – Deggial
    Commented Jul 8, 2019 at 15:27
  • Check your template file inside var/view_preprocessed folder, If your site in production mode Commented Jul 8, 2019 at 15:38
  • It has correct spelling version minified there
    – Deggial
    Commented Jul 8, 2019 at 18:07
  • Did you check in incognito mode? Commented Jul 9, 2019 at 7:13

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.