I have the template that is using the following to render order summary
{{layout handle="sales_email_order_items" order=$order
area="frontend"}}
it is taking the code from the following template
/app/design/frontend/Corra/Mytheme/Magento_Sales/templates/email/items/order/default.phtml
So I want to override this file with my custom module file and use this one.
I created a module "Corra_Sales"
I put the .phtml here
/app/code/Corra/Sales/view/frontend/templates/email/items/order/default.phtml
Also, I created the layout with the file:
/app/code/Corra/Sales/view/frontend/layout/sales_email_order_renderers.xml
The code inside file is:
<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>
Also, I tried with :
<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>
I clear cache, remove var folder, rebuild, etc.
But it still not working, someone could tell me what I am doing wrong that always take this file ->?
/app/design/frontend/Corra/Mytheme/Magento_Sales/templates/email/items/order/default.phtml
Best Answer
the block referenced by sales.email.order.renderers.default is the one to override the template
both layout definitions below should do the work and the first layout definition is now deprecated:
below is the new notation to take over the block template:
Now, the emails in Magento are more complex than normal pages and I have today written a plugin that takes over the function getTemplate for the block
\Magento\Sales\Block\Order\Email\Items\Order\DefaultOrder
and this is finally successfully overriding the template as expected: