Question

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

Was it helpful?

Solution

Need to clear generated folder

rm -rf var/cache/ var/view_preprocessed/ generated/
php bin/magento setup:static-content:deploy -f
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top