Preconditions
app/code/Vendor/ModuleSteps to reproduce
app/code/Vendor/Module/view/frontend/layout/app/code/Vendor/Module/view/frontend/templates/Expected result
Actual result
Additional information
I am trying to remove the SKU from the email notifications which are sent out.
By following the above steps, this works for initial order emails, but not for invoice, shipment or credit memo emails.
Specifically, I have the files below - which work for order emails:
XML File
app/code/Vendor/Module/view/frontend/layout/sales_email_order_renderers.xml
Contents
<?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="Email Creditmemo Items List" design_abstraction="custom">
<body>
<referenceBlock name="sales.email.order.renderers">
<block class="Magento\Sales\Block\Order\Email\Items\Order\DefaultOrder" as="default" template="email/items/order/default.phtml"/>
</referenceBlock>
</body>
</page>
PHTML File
app/code/Vendor/Module/view/frontend/template/email/items/order/default.phtml
Contents
``` /**
// @codingStandardsIgnoreFile
/** @var $block \Magento\Sales\Block\Order\Email\Items\DefaultItems */
/** @var $_item \Magento\Sales\Model\Order\Item */
$_item = $block->getItem();
$_order = $_item->getOrder();
?>
= $block->escapeHtml($_item->getName()) ?>
Similarly, I have the files below for an invoice email, which **does not work**:
**XML File**
`app/code/Vendor/Module/view/frontend/layout/sales_email_order_invoice_renderers.xml`
**Contents**
**PHTML File**
`app/code/Vendor/Module/view/frontend/template/email/items/shipment/default.phtml`
**Contents**
``` <?php
/**
* Copyright 漏 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
// @codingStandardsIgnoreFile
/** @var $_item \Magento\Sales\Model\Order\Item */
$_item = $block->getItem() ?>
<tr>
<td class="item-info<?php if ($block->getItemOptions()): ?> has-extra<?php endif; ?>">
<p class="product-name"><?= $block->escapeHtml($_item->getName()) ?></p>
<?php if ($block->getItemOptions()): ?>
<dl class="item-options">
<?php foreach ($block->getItemOptions() as $option): ?>
<dt><strong><em><?= /* @escapeNotVerified */ $option['label'] ?></em></strong></dt>
<dd>
<?= /* @escapeNotVerified */ nl2br($option['value']) ?>
</dd>
<?php endforeach; ?>
</dl>
<?php endif; ?>
<?php $addInfoBlock = $block->getProductAdditionalInformationBlock(); ?>
<?php if ($addInfoBlock) :?>
<?= $addInfoBlock->setItem($_item->getOrderItem())->toHtml() ?>
<?php endif; ?>
<?= $block->escapeHtml($_item->getDescription()) ?>
</td>
<td class="item-qty"><?= /* @escapeNotVerified */ $_item->getQty() * 1 ?></td>
</tr>
I am also facing the same problem for past few days. I guess this is because of load order of configuration files. Hope there will be a solution.
I have also tried to use the <sequence> tag in module.xml to have it load after Magento_Sales, but no joy.
Up to my observation, because of loading after Magento_Sales, it is not working. I tried to move before Magento_Sales(just for checking), working fine but it affects other things.
Is there anything new on this?
I can still observe this bug and the hotfix (not really) with changing the loading order.
Hi,
Have issue like that but its resolved for me changes are taking effect in mail but getting a exception here is my code.
app/code/Vendor/Module/view/frontend/layout/sales_email_order_renderers.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="Email Creditmemo Items List" design_abstraction="custom">
<body>
<referenceBlock name="sales.email.order.renderers">
<block class="Magento\Sales\Block\Order\Email\Items\Order\DefaultOrder" as="default" template="Vendor_Module::email/items/order/default.phtml"/>
</referenceBlock>
</body>
</page>
Here is my exception :
exception 'Magento\Framework\Exception\LocalizedException' with message 'The element 'sales.email.order.renderers' already has a child with alias 'default'' in /home/amanwebi/public_html/magento21/vendor/magento/framework/Data/Structure.php:611
@devonto, thank you for your report.
The issue is already fixed in 2.2.3, 2.3.0, 2.1.12
For those facing this issue, Just for your knowledge the issue happens in previous magento versions because of following line in core code:
File: vendor/magento/module-sales/view/frontend/layout/sales_email_order_invoice_items.xml
Line: <block class="Magento\Sales\Block\Order\Email\Invoice\Items" name="items" template="email/invoice/items.phtml">
The template value here should have been Magento_Sales::email/invoice/items.phtml
Solution For Magento versions other then 2.2.3, 2.3.0, 2.1.12 where this core bug fix is still not available, following can be done:
<type name="Magento\Sales\Block\Order\Email\Invoice\Items">
<plugin name="vendor_module_sales_order_email_invoice_item" type="Vendor\Module\Plugin\Block\Sales\Order\Email\Invoice\Items" />
</type>
namespace Vendor\Module\Plugin\Block\Sales\Order\Email\Invoice;
class Items
{
public function beforeToHtml(
\Magento\Sales\Block\Order\Email\Invoice\Items $subject
) {
if ($subject->getTemplate() === 'email/invoice/items.phtml') {
$subject->setTemplate('Vendor_Module:email/invoice/items.phtml');
}
}
}
Note that the magento team has already fixed this issue in later versions in the core code. The above fix is for older versions only where the issue still exists.
Hi @magento-engcom-team,
As far as I can see, there's a number of commits and corresponding PRs fixing this issue, most notably 2e70f00 (for 2.3.x branch) and 118c86c (backport for 2.2.x branch)
However, the 2.1.x branch does NOT seem to contain this fix as of latest (2.1.14) patch version.
Please the below file to see that the file discussed above still doesn't contain a name attribute:
https://github.com/magento/magento2/blob/2.1.14/app/code/Magento/Bundle/view/frontend/layout/sales_email_order_shipment_renderers.xml
Could you please correct the issue labels (and possibly comments) in order to show that this issue is not, in fact, fixed in 2.1.x?