又遇到一个奇葩问题。
问题描述:
客户在使用MAGENTO2.3.5 新版本的时候,在后台点击图示中的send tracking information自动跳转到了发送
sales_email_order_guest_template //游客结账时发送
sales_email_orde_template //注册会员发送
幸好有记录邮件日志。依据经验,依次检查:
1。客户在后台选择使用了email template模板功能。
2。VAR下无任何LOG日志,无任何报错日志
3。系统使用的原生MAGENTO版本未修改任何核心。
4。底层系统使用的是suPhp
解决流程记录:
1。修改sales-sales emails中的shipping
后台修改此shipping template为一个test shipping模板,用以下内容代码
{{block class='Magento\\Framework\\View\\Element\\Template' area='frontend' template='Magento_Sales::email/shipment/track.phtml' shipment=$shipment order=$order}}
修改sales-sales emails中的shipping-shipment Email template为自定义的测试邮件模板
然后再次点击 send tracking information。
发送的还是订单确认的EMAIL,
检查数据库表
`email_template`
看相关注释
`is_legacy` 字段注释为 Should the template render in legacy mode 以过去老方法加载模板?
设定此数值全为1
UPDATE `email_template` SET `is_legacy` = '1' WHERE `email_template`.`is_legacy` = 0;
再次发送邮件测试:
tracking Number不显示
打开tracking Number文件所处于的默认位置:
/vendor/magento/module-sales/view/frontend/templates/email/shipment/track.phtml
一个一个测试其代码调用是否有效,发现URL是有问题,这里修改删除物流单号的链接
<?php foreach ($trackCollection as $_item) : ?> <tr> <td><?= $block->escapeHtml($_item->getTitle()) ?>:</td> <td> <?= $block->escapeHtml($_item->getNumber()) ?> </td> </tr> <?php endforeach ?>
再次保存并测试发现可正常发送物流跟踪信息,但是多个物流要跟踪的话又不显示 ,那么此处修改为:
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ ?> <?php /* @var \Magento\Framework\View\Element\Template $block */ ?> <?php $_shipment = $block->getShipment() ?> <?php /* @var \Magento\Sales\Model\Order $_order */ $_order = $block->getOrder() ?> <?php if ($_shipment && $_order) : ?> <?php $trackCollection = $_order->getTracksCollection($_shipment->getId()) ?> <?php $trackCollection = $_shipment->getTracksCollection() ?> <?php if ($trackCollection) : ?> <br /> <table class="shipment-track"> <thead> <tr> <th><?= $block->escapeHtml(__('Shipped By')) ?></th> <th><?= $block->escapeHtml(__('Tracking Number')) ?></th> </tr> </thead> <tbody> <?php foreach ($trackCollection as $_item) : ?> <tr> <td><?= $block->escapeHtml($_item->getTitle()) ?>:</td> <td> <?= $block->escapeHtml($_item->getNumber()) ?> </td> </tr> <?php endforeach ?> </tbody> </table> <?php endif; ?> <?php endif; ?>
保存之后,已经能正常收到邮件
出现BUG不可怕 ,可怕的就是面象百度谷歌编程的这些没有记录,才是 关键的问题。