Magento2: [2.1.0-rc3] Loading certain email templates in backend doesn't work

Created on 20 Jun 2016  路  23Comments  路  Source: magento/magento2

Steps to reproduce

  1. Install Magento 2.1.0-rc3 using composer
  2. In the backend, go to Marketing => Email Templates
  3. Click the 'Add a new Template' button
  4. Choose 'New Order' as Template and click the 'Load Template' button

    Expected result

  5. The template is loaded without errors

    Actual result

  6. Error message appears: The template did not load. Please review the log for details.
    In the exception.log file, I see:

[2016-06-20 10:06:47] main.CRITICAL: Zend_Json_Exception: Decoding failed: Syntax error in vendor/magento/zendframework1/library/Zend/Json.php:97
Stack trace:
#0 vendor/magento/module-email/Model/Template.php(306): Zend_Json::decode('{"var formatted...')
#1 vendor/magento/module-email/Model/Template.php(320): Magento\Email\Model\Template->_parseVariablesString('{"var formatted...')
#2 vendor/magento/module-email/Controller/Adminhtml/Email/Template/DefaultTemplate.php(52): Magento\Email\Model\Template->getVariablesOptionArray(true)
#3 var/generation/Magento/Email/Controller/Adminhtml/Email/Template/DefaultTemplate/Interceptor.php(24): Magento\Email\Controller\Adminhtml\Email\Template\DefaultTemplate->execute()
#4 vendor/magento/framework/App/Action/Action.php(102): Magento\Email\Controller\Adminhtml\Email\Template\DefaultTemplate\Interceptor->execute()
#5 vendor/magento/module-backend/App/AbstractAction.php(226): Magento\Framework\App\Action\Action->dispatch(Object(Magento\Framework\App\Request\Http))
#6 vendor/magento/framework/Interception/Interceptor.php(74): Magento\Backend\App\AbstractAction->dispatch(Object(Magento\Framework\App\Request\Http))
#7 vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Email\Controller\Adminhtml\Email\Template\DefaultTemplate\Interceptor->___callParent('dispatch', Array)
#8 vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Email\\C...', 'dispatch', Object(Magento\Email\Controller\Adminhtml\Email\Template\DefaultTemplate\Interceptor), Array, 'adminAuthentica...')
#9 vendor/magento/module-backend/App/Action/Plugin/Authentication.php(143): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#10 vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch(Object(Magento\Email\Controller\Adminhtml\Email\Template\DefaultTemplate\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#11 vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Email\\C...', 'dispatch', Object(Magento\Email\Controller\Adminhtml\Email\Template\DefaultTemplate\Interceptor), Array, 'adminMassaction...')
#12 vendor/magento/module-backend/App/Action/Plugin/MassactionKey.php(33): Magento\Email\Controller\Adminhtml\Email\Template\DefaultTemplate\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#13 vendor/magento/framework/Interception/Interceptor.php(142): Magento\Backend\App\Action\Plugin\MassactionKey->aroundDispatch(Object(Magento\Email\Controller\Adminhtml\Email\Template\DefaultTemplate\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#14 var/generation/Magento/Email/Controller/Adminhtml/Email/Template/DefaultTemplate/Interceptor.php(39): Magento\Email\Controller\Adminhtml\Email\Template\DefaultTemplate\Interceptor->___callPlugins('dispatch', Array, Array)
#15 vendor/magento/framework/App/FrontController.php(55): Magento\Email\Controller\Adminhtml\Email\Template\DefaultTemplate\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#16 vendor/magento/framework/Interception/Interceptor.php(74): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))
#17 vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)
#18 vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'install')
#19 vendor/magento/framework/Module/Plugin/DbStatusValidator.php(69): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#20 vendor/magento/framework/Interception/Interceptor.php(142): Magento\Framework\Module\Plugin\DbStatusValidator->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#21 var/generation/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, Array)
#22 vendor/magento/framework/App/Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#23 vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch()
#24 pub/index.php(37): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))
#25 {main} [] []

Discoveries

After searching a bit around, it looks like the json in the <!--@vars ... @--> isn't valid in the file vendor/magento/module-sales/view/frontend/email/order_new.html:

<!--@vars {
"var formattedBillingAddress|raw":"Billing Address",
"var order.getEmailCustomerNote()":"Email Order Note",
"var order.increment_id":"Order Id",
"layout handle=\"sales_email_order_items\" order=$order area=\"frontend\"":"Order Items Grid",
"var payment_html|raw":"Payment Details",
"var formattedShippingAddress|raw":"Shipping Address",
"var order.getShippingDescription()":"Shipping Description"
"var shipping_msg":"Shipping message"
} @-->

There is a trailing comma missing after "Shipping Description"
If I add a comma, the issue is fixed.

This issue also exists in the order_new_guest.html file, I haven't took the time to check all other email templates, but maybe some other ones might have the same problem?

Ready for Work bug report

Most helpful comment

This is still a bug in Magento 2.1.

All 23 comments

Issue got introduced in https://github.com/magento/magento2/commit/44791d5a8e2b3fc2b0dacc72300030e2df4398ff

Looks like the same templates in the luma theme also got broken.

Pinging @naydav

Hi @hostep ,
thank you for your report and your PR. Internal ticket MAGETWO-54786 was created to process it.

This is still a bug in Magento 2.1.

Facing the same problem with Magento 2.1 when trying to load New Order template in backend for translation purposes.

same issue 2.1 / php7/ nginx

Facing the same problem with Magento 2.1.
And solved @hostep's PR. thx.

Same issue. Thanks @hostep

Magento 2.1.0 and same issue.

Hi ,
fix 02bc3fc was delivered to develop branch. See #5116

Thanks @NadiyaS , I applied patch and it works as expected.

Thanks it worked. saved valuable time :+1:

Problem continue with Magento 2.1.2
Fyi

@rbostan the fix was not included to 2.1.2 release. Now you may find it in develop branch only.

@SerhiyShkolyarenko So how hard would this have been to include in 2.1.2? It's just adding a comma to four files. I'm trying to understand the methodology here. I understand needing a cutoff point, at some point you have to ship what you have. But a lot of these fixes are no brainers and it's hard to understand why many things that had fixes prior to 2.1.2 were not included.

From what I gather, 2.1.2 was only a security update, so no fixes were included.

@olysenko this is not the same issue...
this issue is solved by adding the ',' but my issue is because of the %account_url.
Besides in this issue its only an error on preview and in my issue I can't save the template...

The issue still exists. Can someone explain how it can take more than 5 months to add a comma to four files?

I ran into this also, rather frustrating that it was fixed, but not introduced, could have saved me time trying to figure out what I assumed was something I did wrong. Would like to know why there are several fixes out there that dont make it into the mainline.

Hi in my site when i load new order email template it shows error and Error message appears: The template did not load. Please review the log for details

I updated the line "var order.getShippingDescription()":"Shipping Description", with a comma "," at the end of line as suggested in some support pages to resolve the template load issue. Now i can load new order email template but the measure problem is that when i click to preview template or save template it goes a 404 page and nothing happen.

Some support page are saying to Install Magento 2.1.0-rc3 using composer.

What stand for Magento 2.1.0-rc3 and where i can get it download and install or there is any other option to resolve this issue . i want to keep the megento 2.1.0 version for my website.

Please reply with the correct solution .

Hi @mithname20,
if you encountered a new problem please, create additional issue according to Issue reporting guidelines.
Thanks

This was fixed in June. When are we going to see a fix?!

Hi Guys, the fix for this is scarily simple

In the file /public_html/vendor/magento/module-sales/view/frontend/email/order_new.html
on line ...about 16ish find this code

"var order.getShippingDescription()":"Shipping Description" and simply add a comma after it , like below

"var order.getShippingDescription()":"Shipping Description",

Like magic the template will load

Was this page helpful?
0 / 5 - 0 ratings