【发布时间】:2018-09-19 15:19:15
【问题描述】:
我有使用以下内容呈现订单摘要的模板
{{layout handle="sales_email_order_items" order=$order area="前端"}}
它从以下模板中获取代码
/app/design/frontend/Corra/Mytheme/Magento_Sales/templates/email/items/order/default.phtml
所以我想用我的自定义模块文件覆盖这个文件并使用这个。
我创建了一个模块“Corra_Sales”
我把.phtml放在这里
/app/code/Corra/Sales/view/frontend/templates/email/items/order/default.phtml
另外,我用文件创建了布局:
/app/code/Corra/Sales/view/frontend/layout/sales_email_order_renderers.xml
文件里面的代码是:
<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="Corra_Sales::email/items/order/default.phtml"/>
</referenceBlock>
</body>
</page>
另外,我尝试过:
<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">
<arguments>
<argument name="template" xsi:type="string">Corra_Sales::email/items/order/default.phtml</argument>
</arguments>
</referenceBlock>
</body>
</page>
我清除缓存、删除 var 文件夹、重建等。
但它仍然无法正常工作,有人可以告诉我我做错了什么总是拿这个文件->?
/app/design/frontend/Corra/Mytheme/Magento_Sales/templates/email/items/order/default.phtml
【问题讨论】:
-
正如官方文档(devdocs.magento.com/guides/v2.2/frontend-dev-guide/templates/…)所说——“主题模板覆盖模块模板”
-
如果你能解释一下你为什么要这样做,也许我们能想出办法
-
@AleksandrasGavinčiuk 我需要在模板中显示自定义功能,但我无法修改设计中的模板,这就是我创建新模块的原因。
-
为什么不能修改主题文件夹中的那个?你真的需要覆盖它,或者你可以在另一个模板中添加你的功能?
-
为什么不能修改主题文件夹中的那个?因为这是客户端的要求:S 您实际上需要覆盖它,或者您可以在另一个模板中添加您的功能?我需要覆盖上述文件。
标签: php magento magento2 magento2.1