2

Well I have an idea to create custom module in magento2 but when it comes to override code functionality I stucks.

for example I have to override this file default.phtml in

/vendor/magento/module-sales/view/frontend/templates/email/items/order

to gain functionality like product thumbnail and product url in order confirmation mail so how to achieve this.

I have done this in core files which I want to do using overriding. I am confused on overriding .phtml file, and class file so how to achieve this?

0

basically here block has no name in this layout sales_email_order_renderers.xml

So you can trick this thing

create a blank prefrence of this class Magento\Sales\Block\Order\Email\Items\Order\DefaultOrder

in your module and put default.phtml in your modules directory

view/frontend/template/email/items/order/default.phtml

so by doing this , magento find this path in your moduleemail/items/order/default.phtml file instead of sales module

Hope this will help you

-1

For override the .phtml files of any core module go through the below steps:

Create the directory in your custom theme like the below:

app\design\frontend\Vendor\Theme Name/Magento_Sales/templates/email/items/order/default.phtml

And than you can put your customization code in this file for better understand go through the Magento 2 devdocs Templates overriding reference

We can do same thing for any Core module.

Hope this help.

  • yeah but i have to add new theme in my module which will result in a complete layout changed than that of its parent theme..i just want to use a phtml file in existing theme to override..for this i have to create a new custom theme???well does it having any alternatives so that i can override it through module...if i create a custom theme i need to set it from admin which is not a good idea so how to do it? – Yogesh Raghav Mar 8 '17 at 8:27
  • Are you are using the 'LUMA' theme? – mageDev0688 Mar 8 '17 at 8:33
  • no its purchased theme->SM Topshop theme Sm/topshop – Yogesh Raghav Mar 8 '17 at 8:34
  • You can use the same theme, could you please let me know vendor_name? – mageDev0688 Mar 8 '17 at 8:36
  • Its Sm path is /app/code/Sm/Topshop Sm is vendor and Topshop is a theme folder inside Sm – Yogesh Raghav Mar 8 '17 at 8:37

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.