3

There. After success migration work, i need to handle devlopment work,ugh. I'm a mad newbie about Magento2 so could you let me know how to overwrite the default phtml file under vendor/magento .. folder.

FYI,

Currently, our website has no theme (it means default Luma theme, right?) And i was trying to overwrite some phtml files using order confirmation email. (it seems that it is not much related with which theme i'm using tho).

  1. Copied templates need to make override in:

/public_html/vendor/magento/module-sales/view/frontend/templates/email/items.phtml

  1. Location contain templates using to override:

/public_html/app/design/frontend/Magento/default/Magento_Sales/templates/email/items.phtml

  1. Run commands after modification

    php bin/magento setup:static-content:deploy
    find pub/ -type f ! -perm 0644 -exec chmod 0644 {} \;
    find pub/ -type d ! -perm 0755 -exec chmod 0755 {} \;
    

What should i do? Thank you

2

Location seems wrong

It should be

public_html/app/design/frontend/{Vendor}/{Themename}/Magento_Sales/templates/email/items.phtml

Instead of

public_html/app/design/frontend/Magento/default/Magento_Sales/templates/email/items.phtml


As your your theme is luma And this theme is register under vendor/magento/theme-frontend-luma

So,Other should modify code at this located

Create a template file items.phtml at vendor/magento/theme-frontend-luma\Magento_Sales\templates\email.

And that new items.phtml you can work.

Via custom module

If you donot want to work at direct vendor folder then you need create a custom module

This module should consist of below files:

  • app/code/app/code/{vendorname}/{Company}/registration.php
  • app/code/{vendorname}/{Company}/composer.json
  • app/code/{vendorname}/{Company}/etc/module.xml

then Create a layout file sales_email_order_items.xml at app/code/{vendorname}/{Company}/view/frontend/layout

On this sales_email_order_items.xml add below code for change the template via layout.

<?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 Order Items List" design_abstraction="custom">
    <body>
     <referenceBlock name="items">
         <arguments>
         <argument name="template" xsi:type="string">{vendorname}_{Company}::sales/email/items.phtml</argument>
         </arguments>
     </referenceBlock>
    </body>
</page>

Now new template phtml is located at app/code/{vendorname}/{Company}/view/frontend/templates/sales/email/items.phtml.

Now you do after you want.

After this your should do below

delete all file from var/cache and var/view_preprocessed and page_cache using rm -rfvar/cacheandrm -rf var/view_preprocessed,rm -rf var/page_cache`

  • Thank you for answering me , Amit. By the way, do i have to put layout file? – 3CE Oct 5 '17 at 14:43
  • It doesn't work in magento 2.1.9 – 3CE Oct 5 '17 at 15:33
  • is this work?.. – Amit Bera Oct 6 '17 at 15:40
  • Yes! It works ! – 3CE Oct 18 '17 at 19:17
  • Happy to hear that – Amit Bera Oct 18 '17 at 19:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.