2

Magento Transactional Emails (from Admin)

How do I get Magento to save the templates exactly how they are entered in Admin? For me it drops \ that escape characters in the code making it impossible for Magneto to re-open the template once its saved.

Example:

After creating or loading a new template in admin, I save the cms page with code like this:

{"store url=\"\"":"Store Url",
"var logo_url":"Email Logo Image Url",
"var logo_alt":"Email Logo Image Alt",
"htmlescape var=$order.getCustomerName()":"Customer Name",
"var store.getFrontendName()":"Store Name",
"store url=\"customer/account/\"":"Customer Account Url",
"var order.increment_id":"Order Id",
"var order.getCreatedAtFormated('long')":"Order Created At (datetime)",
"var order.getBillingAddress().format('html')":"Billing Address",
"var payment_html":"Payment Details",
"var order.getShippingAddress().format('html')":"Shipping Address",
"var order.getShippingDescription()":"Shipping Description",
"layout handle=\"sales_email_order_items\" order=$order":"Order Items Grid",
"var order.getEmailCustomerNote()":"Email Order Note"}

Then after I try to re-open it, I get an error message and Magento refuses to even preview let alone edit the template.

There has been an error processing your request The error has been logged and we will review it's contents. Clear your cookies for pumpunderwear.* and please re-try. If you keep seeing this again and again, come back later and we should have this fixed. Decoding failed: Syntax error

Trace:

#0 /web/store/app/code/core/Mage/Core/Model/Email/Template.php(590): Zend_Json::decode('{"store url="""...')
#1 /web/store/app/code/core/Mage/Core/Model/Email/Template.php(604): Mage_Core_Model_Email_Template->_parseVariablesString('{"store url="""...')
#2 /web/store/app/code/core/Mage/Adminhtml/Block/System/Email/Template/Edit/Form.php(186): Mage_Core_Model_Email_Template->getVariablesOptionArray(true)
#3 /web/store/app/code/core/Mage/Adminhtml/Block/System/Email/Template/Edit/Form.php(112): Mage_Adminhtml_Block_System_Email_Template_Edit_Form->getVariables()
#4 /web/store/app/code/core/Mage/Adminhtml/Block/Widget/Form.php(144): Mage_Adminhtml_Block_System_Email_Template_Edit_Form->_prepareForm()
#5 /web/store/app/code/core/Mage/Core/Block/Abstract.php(918): Mage_Adminhtml_Block_Widget_Form->_beforeToHtml()
#6 /web/store/app/code/core/Mage/Core/Block/Abstract.php(637): Mage_Core_Block_Abstract->toHtml()
#7 /web/store/app/code/core/Mage/Core/Block/Abstract.php(581): Mage_Core_Block_Abstract->_getChildHtml('form', true)
#8 /web/store/app/code/core/Mage/Adminhtml/Block/System/Email/Template/Edit.php(235): Mage_Core_Block_Abstract->getChildHtml('form')
#9 /web/store/app/design/adminhtml/default/default/template/system/email/template/edit.phtml(108): Mage_Adminhtml_Block_System_Email_Template_Edit->getFormHtml()
#10 /web/store/app/code/core/Mage/Core/Block/Template.php(241): include('/var/www/www.pu...')
#11 /web/store/app/code/core/Mage/Core/Block/Template.php(272): Mage_Core_Block_Template->fetchView('adminhtml/defau...')
#12 /web/store/app/code/core/Mage/Core/Block/Template.php(286): Mage_Core_Block_Template->renderView()
#13 /web/store/app/code/core/Mage/Adminhtml/Block/Template.php(81): Mage_Core_Block_Template->_toHtml()
#14 /web/store/app/code/core/Mage/Core/Block/Abstract.php(919): Mage_Adminhtml_Block_Template->_toHtml()
#15 /web/store/app/code/core/Mage/Core/Block/Text/List.php(43): Mage_Core_Block_Abstract->toHtml()
#16 /web/store/app/code/core/Mage/Core/Block/Abstract.php(919): Mage_Core_Block_Text_List->_toHtml()
#17 /web/store/app/code/core/Mage/Core/Block/Abstract.php(637): Mage_Core_Block_Abstract->toHtml()
#18 /web/store/app/code/core/Mage/Core/Block/Abstract.php(581): Mage_Core_Block_Abstract->_getChildHtml('content', true)
#19 /web/store/app/design/adminhtml/default/default/template/page.phtml(74): Mage_Core_Block_Abstract->getChildHtml('content')
#20 /web/store/app/code/core/Mage/Core/Block/Template.php(241): include('/var/www/www.pu...')
#21 /web/store/app/code/core/Mage/Core/Block/Template.php(272): Mage_Core_Block_Template->fetchView('adminhtml/defau...')
#22 /web/store/app/code/core/Mage/Core/Block/Template.php(286): Mage_Core_Block_Template->renderView()
#23 /web/store/app/code/core/Mage/Adminhtml/Block/Template.php(81): Mage_Core_Block_Template->_toHtml()
#24 /web/store/app/code/core/Mage/Core/Block/Abstract.php(919): Mage_Adminhtml_Block_Template->_toHtml()
#25 /web/store/app/code/core/Mage/Core/Model/Layout.php(555): Mage_Core_Block_Abstract->toHtml()
#26 /web/store/app/code/core/Mage/Core/Controller/Varien/Action.php(390): Mage_Core_Model_Layout->getOutput()
#27 /web/store/app/code/core/Mage/Adminhtml/controllers/System/Email/TemplateController.php(109): Mage_Core_Controller_Varien_Action->renderLayout()
#28 /web/store/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Adminhtml_System_Email_TemplateController->editAction()
#29 /web/store/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('edit')
#30 /web/store/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#31 /web/store/app/code/core/Mage/Core/Model/App.php(365): Mage_Core_Controller_Varien_Front->dispatch()
#32 /web/store/app/Mage.php(684): Mage_Core_Model_App->run(Array)
#33 /web/store/index.php(135): Mage::run('', 'store')
#34 {main}

It seems to be a problem decoding the store URL variable

Zend_Json::decode('{"store url="""...')

When I check the database, I see that it has been saved differently then how I had saved it in Admin. It no longer has the quotes escaped and is missing a few slashes and other formatting changes. It now looks like this:

{"store url=""":"Store Url",
"var logo_url":"Email Logo Image Url",
"var logo_alt":"Email Logo Image Alt",
"htmlescape var=$order.getCustomerName()":"Customer Name",
"var store.getFrontendName()":"Store Name",
"store url="customer/account/"":"Customer Account Url",
"var order.increment_id":"Order Id",
"var order.getCreatedAtFormated('long')":"Order Created At (datetime)",
"var order.getBillingAddress().format('html')":"Billing Address",
"var payment_html":"Payment Details",
"var order.getShippingAddress().format('html')":"Shipping Address",
"var order.getShippingDescription()":"Shipping Description",
"layout handle="sales_email_order_items" order=$order":"Order Items Grid",
"var order.getEmailCustomerNote()":"Email Order Note"}

I changed it in the database directly, and then I was able to open the template again in admin, but after I save it, the same thing happens. What can I do to have it keep the forward slashes infront of the quotes etc.?

Is this a Magento code issue or a server/database encoding issue?

Thanks!!

  • Server is Nginx for static content
  • Apache2 for dynamic.
  • Web server on AWS EC2
  • DB is separate server AWS EC2
  • php 5.5.30
  • mysql 5.6.25

0 Answers0