Php Magento发票电子邮件:订购的项目不可见
发票电子邮件不显示订购项目表(发票PDF中没有问题)。我的模板包含以下代码:Php Magento发票电子邮件:订购的项目不可见,php,email,magento,Php,Email,Magento,发票电子邮件不显示订购项目表(发票PDF中没有问题)。我的模板包含以下代码: {{layout area="frontend" handle="sales_email_order_invoice_items" invoice=$invoice order=$order}} 但是,电子邮件中缺少这一部分。我试图找到生成HTML的代码,我想sales.xml告诉我查看“email/order/invoice/items.phtml”模板文件。但改变内容似乎没有任何效果 我应该从哪里开始解决这个问题
{{layout area="frontend" handle="sales_email_order_invoice_items" invoice=$invoice order=$order}}
但是,电子邮件中缺少这一部分。我试图找到生成HTML的代码,我想sales.xml告诉我查看“email/order/invoice/items.phtml
”模板文件。但改变内容似乎没有任何效果
我应该从哪里开始解决这个问题
这是sales.xml中的部分:
<sales_email_order_invoice_items>
<block type="sales/order_email_invoice_items" name="items" template="email/order/invoice/items.phtml">
<action method="addItemRender"><type>default</type><block>sales/order_email_items_default</block><template>email/order/items/invoice/default.phtml</template></action>
<action method="addItemRender"><type>grouped</type><block>sales/order_email_items_order_grouped</block><template>email/order/items/invoice/default.phtml</template></action>
<block type="sales/order_invoice_totals" name="invoice_totals" template="sales/order/totals.phtml">
<action method="setLabelProperties"><value>colspan="3" align="right" style="padding:3px 9px"</value></action>
<action method="setValueProperties"><value>align="right" style="padding:3px 9px"</value></action>
<block type="tax/sales_order_tax" name="tax" template="tax/order/tax.phtml"/>
</block>
</block>
<block type="core/text_list" name="additional.product.info" />
</sales_email_order_invoice_items>
defaultsales/order\u email\u items\u defaultemail/order/items/invoice/default.phtml
groupedsales/order\u email\u items\u order\u groupedemail/order/items/invoice/default.phtml
colspan=“3”align=“right”style=“padding:3px 9px”
align=“right”style=“padding:3px 9px”
您正朝着正确的方向前进。由于您找到了句柄,只需稍加搜索,就可以在sales.xml文件中找到sales\u email\u order\u invoice\u items句柄
<sales_email_order_invoice_items>
<block type="sales/order_email_invoice_items" name="items" template="email/order/invoice/items.phtml">
<action method="addItemRender"><type>default</type><block>sales/order_email_items_default</block><template>email/order/items/invoice/default.phtml</template></action>
<action method="addItemRender"><type>grouped</type><block>sales/order_email_items_order_grouped</block><template>email/order/items/invoice/default.phtml</template></action>
<block type="sales/order_invoice_totals" name="invoice_totals" template="sales/order/totals.phtml">
<action method="setLabelProperties"><value>colspan="3" align="right" style="padding:3px 9px"</value></action>
<action method="setValueProperties"><value>align="right" style="padding:3px 9px"</value></action>
<block type="tax/sales_order_tax" name="tax" template="tax/order/tax.phtml"/>
</block>
</block>
<block type="core/text_list" name="additional.product.info" />
</sales_email_order_invoice_items>
defaultsales/order\u email\u items\u defaultemail/order/items/invoice/default.phtml
groupedsales/order\u email\u items\u order\u groupedemail/order/items/invoice/default.phtml
colspan=“3”align=“right”style=“padding:3px 9px”
align=“right”style=“padding:3px 9px”
电子邮件/order/invoice/items.phtml文件负责发票的主模板
电子邮件/order/items/invoice/default.phtml很可能就是您要查找的内容,它将用于每个产品显示其信息
因此,只需将email/order/items/invoice/default.phtml复制到您自己的模板文件夹中,并在该文件中更改您需要更改的内容
我希望这将对您有所帮助。您可以从中找到解决方案!我不确定100%,但这个问题可能是由Magento 2.3.4+的新更新引起的 从Magento 2.3.4+,Magento团队为电子邮件模板添加了一个新属性,有严格模式或传统模式 如果从后端为销售对象(订单、发票、装运)添加新的电子邮件模板,则该模板可能无法正常工作。示例订单项网格未显示在电子邮件中。因为它们不允许我们将对象传递给模板对象,如块或布局句柄。只允许使用数组或标量变量 您可以在文件\Magento\Framework\Filter\VariableResolver\StricResolver–函数解析中看到
if (isset($stackArgs[$last]['variable'])
&& (is_scalar($stackArgs[$last]['variable']) || is_array($stackArgs[$last]['variable']))
) {
// If value for construction exists set it
$result = $stackArgs[$last]['variable'];
}
所有从后端创建的新电子邮件都将使用严格模式作为默认模式,不会在后端对其进行修改。您必须通过数据库管理来更改它。请在表email_template中查找电子邮件模板数据,然后将“is_legacy”字段更改为1。如果您使用的是Magento 2.3.4、2.3.5,此问题的临时解决方案是使用订购的项目更新电子邮件模板,并使用is_legacy=1。例如:
update email_template set is_legacy = 1 where orig_template_code = 'sales_email_order_template';
您需要在数据库表中为您使用的模板设置email\u template列is\u legacy=1谢谢您的解释!是否可能正在缓存这些模板文件?当我在“app/design/frontend/base/default/template/email/order/items/invoice/default.phtml”中更改某些内容时,我在新的发票电子邮件中看不到任何更改。您是否为电子邮件添加了自定义扩展名,或者请从主题“sales\u email\u order\u invoice\u items”中检查sales.xml您使用的发票模板。我添加了sales.xml代码。我认为模板是“app/design/frontend/base/default/template/email/order/items/invoice/default.pht”还是我错了?