-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Description
The theme templates overrides are not resolved correctly if we're in an environment emulation cross-area (e.g.: we're in adminhtml emulating frontend).
My particular case has been this: I have a custom template overriding the payment method info template, I login in the Magento admin, find an order, click "Send email". The email won't have the overridden template.
Techincal details
To render the payment method info block Magento emulates the order's store in the frontend area (https://github.com/magento/magento2/blob/develop/app/code/Magento/Payment/Helper/Data.php#L208) and then calls toHtml() on the block. The template file resolution will pass through Magento\Framework\View\Asset\Repository::updateDesignParams(), will execute line #145 setting $theme to the theme ID, and will execute line #149 that tries to load the theme by full path rather than by ID, thus returning no theme.
The code of this method normally works because if we're not in an environment emulation cross-area, the execution will not fall into that elseif and will not execute line #145 going likely into line #154.
I'm going to submit a pull request with what I believe is a possible solution.
Preconditions
- Magento CE 2.1.7
Steps to reproduce
- Create a new custom frontend template that inherits from Magento/Luma
- Inside the template directory (
app/design/frontend/<vendor>/<themeName>) create the folderMagento_OfflinePayments/templates/info/and createcheckmo.phtmlinto it. The content of this file can be, for example, "Payment method override test" - Go on Magento admin, set the store design to use this template and flush cache
- Go on frontend, login, complete an order with payment method "Check / Money order"
- Go in your account area, open this order and verify that it shows "Payment method override test" as payment method
- Go on Magento admin, find this order and click "Send email" on it
Expected result
- The email received has "Payment method override test" as well as payment method
Actual result
- The email doesn't have "Payment method override test" but it has the standard payment method label provided by the module template