Modelos de email do administrador


11

Eu tenho esse problema estranho com os emails transacionais do Magento. Eu tenho os mesmos arquivos nos meus servidores locais, de desenvolvimento e produção.

Em Admin> Sistema> Emails Transacionais> Adicionar novo modelo

Seleciono um modelo na lista suspensa e deixo o local em inglês EUA. Os campos não são preenchidos nos servidores de desenvolvimento e produção, mas estão funcionando corretamente no local. Eu pensei que era um erro de permissão, mas após a inspeção, descobri que a chamada ajax que carregava o código do arquivo de modelo está funcionando corretamente:

O que pode estar errado?

/index.php/admin/system_email_template/defaultTemplate/key/7ac9c5866202e5cb29be84299bf2ebad/?isAjax=true
Response: 

{
    "template_type": 2,
    "template_subject": "{{var store.getFrontendName()}}: Shipment # {{var shipment.increment_id}} update",
    "orig_template_variables": "{\"store url=\\\"\\\"\":\"Store Url\",\"var logo_url\":\"Email Logo Image Url\",\"var logo_alt\":\"Email Logo Image Alt\",\"htmlescape var=$billing.getName()\":\"Guest Customer Name\",\"var order.increment_id\":\"Order Id\",\"var order.getStatusLabel()\":\"Order Status\",\"var comment\":\"Order Comment\",\"var store.getFrontendName()\":\"Store Name\"}",
    "template_styles": "body,td { color:#2f2f2f; font:11px\/1.35em Verdana, Arial, Helvetica, sans-serif; }",
    "template_text": "\n\n\n\n<script type="text/javascript">window.NREUM||(NREUM={}),__nr_require=function(t,n,e){function r(e){if(!n[e]){var o=n[e]={exports:{}};t[e][0].call(o.exports,function(n){var o=t[e][1][n];return r(o?o:n)},o,o.exports)}return n[e].exports}if("function"==typeof __nr_require)return __nr_require;for(var o=0;o<e.length;o++)r(e[o]);return r}({D5DuLP:[function(t,n){function e(t,n){var e=r[t];return e?e.apply(this,n):(o[t]||(o[t]=[]),void o[t].push(n))}var r={},o={};n.exports=e,e.queues=o,e.handlers=r},{}],handle:[function(t,n){n.exports=t("D5DuLP")},{}],G9z0Bl:[function(t,n){function e(){var t=l.info=NREUM.info;if(t&&t.agent&&t.licenseKey&&t.applicationID&&p&&p.body){l.proto="https"===f.split(": ")[0]||t.sslForHttp?"https: //":"http: //",i("mark",["onload",a()]);var n=p.createElement("script");n.src=l.proto+t.agent,p.body.appendChild(n)}}function r(){"complete"===p.readyState&&o()}function o(){i("mark",["domContent",a()])}function a(){return(new Date).getTime()}var i=t("handle"),u=window,p=u.document,s="addEventListener",c="attachEvent",f=(""+location).split("?")[0],l=n.exports={offset:a(),origin:f,features:[]};p[s]?(p[s]("DOMContentLoaded",o,!1),u[s]("load",e,!1)):(p[c]("onreadystatechange",r),u[c]("onload",e)),i("mark",["firstbyte",a()])},{handle:"D5DuLP"}],loader:[function(t,n){n.exports=t("G9z0Bl")},{}]},{},["G9z0Bl"]);</script><body style=\"background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;\">\n<div style=\"background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;\">\n<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" height=\"100%\" width=\"100%\">\n<tr>\n    <td align=\"center\" valign=\"top\" style=\"padding:20px 0 20px 0\">\n        <!-- [ header starts here] -->\n        <table bgcolor=\"#FFFFFF\" cellspacing=\"0\" cellpadding=\"10\" border=\"0\" width=\"650\" style=\"border:1px solid #E0E0E0;\">\n            <tr>\n                <td valign=\"top\" style=\"background-color: #f4f4f4; text-align: center;\"><a href=\"{{store url=\"\"}}\"><img src=\"{{var logo_url}}\" alt=\"{{var logo_alt}}\" style=\"margin-bottom:10px;\" border=\"0\"\/><\/a><\/td>\n            <\/tr>\n            <!-- [ middle starts here] -->\n            <tr>\n                <td valign=\"top\">\n                    <h1 style=\"color: #f47321; font-size:22px; font-weight:normal; line-height:22px; margin:0 0 11px 0;\">Dear {{htmlescape var=$billing.getName()}},<\/h1>\n                    <p style=\"font-size:12px; line-height:16px; margin:0 0 10px 0;\">\n                        Your order # {{var order.increment_id}} has been <br\/>\n                        <strong>{{var order.getStatusLabel()}}<\/strong>.\n                    <\/p>\n                    <p style=\"font-size:12px; line-height:16px; margin:0 0 10px 0;\">{{var comment}}<\/p>\n                    <p style=\"font-size:12px; line-height:16px; margin:0;\">\n                        If you have any questions, please feel free to contact us at\n                        <a href=\"mailto:{{config path='trans_email\/ident_support\/email'}}\" style=\"color:#1E7EC8;\">{{config path='trans_email\/ident_support\/email'}}<\/a>\n                        or by phone at {{config path='general\/store_information\/phone'}}.\n                    <\/p>\n                <\/td>\n            <\/tr>\n            <tr>\n                <td bgcolor=\"#f4f4f4\" align=\"center\" style=\"background:#f4f4f4; text-align:center;\"><center><p style=\"font-size:12px; margin:0;\">Thank you again, <strong style=\"color: #f47321;\">{{var store.getFrontendName()}}<\/strong><\/p><\/center><\/td>\n            <\/tr>\n        <\/table>\n    <\/td>\n<\/tr>\n<\/table>\n<\/div>\n<\/body>",
    "template_id": "sales_email_shipment_comment_guest_template",
    "orig_template_code": "sales_email_shipment_comment_guest_template",
    "template_variables": "{\"label\":\"Template Variables\",\"value\":[{\"value\":\"{{store url=\\\"\\\"}}\",\"label\":\"Store Url\"},{\"value\":\"{{var logo_url}}\",\"label\":\"Email Logo Image Url\"},{\"value\":\"{{var logo_alt}}\",\"label\":\"Email Logo Image Alt\"},{\"value\":\"{{htmlescape var=$billing.getName()}}\",\"label\":\"Guest Customer Name\"},{\"value\":\"{{var order.increment_id}}\",\"label\":\"Order Id\"},{\"value\":\"{{var order.getStatusLabel()}}\",\"label\":\"Order Status\"},{\"value\":\"{{var comment}}\",\"label\":\"Order Comment\"},{\"value\":\"{{var store.getFrontendName()}}\",\"label\":\"Store Name\"}]}",
    "orig_template_used_default_for": [

    ]
}

Respostas:



9

Eu tenho o mesmo problema em um dos meus projetos em que estou trabalhando e descobri por que isso está acontecendo, por isso estou postando aqui, para que possa ser útil para outras pessoas.

  • No site ativo, ele não carrega alguns dos modelos de email padrão no momento da criação de um novo modelo com base neles, mas está funcionando perfeitamente no meu site local.

  • Portanto, comparei as respostas ajax que estou recebendo e soube que no site ao vivo, o script é adicionado no início da resposta, o que causa esse problema.

Script que causa o problema:

    (window.NREUM || (NREUM = {})).loader_config = {xpid:"UgcCVVFTGwcDV1lXDwk="};
window.NREUM || (NREUM = {}), __nr_require = function(t, e, n) {
    function r(n) {
if (!e[n]) {
var o = e[n] = {exports: {}};
t[n][0].call(o.exports, function(e) {
var o = t[n][1][e];
return r(o ? o : e)
}, o, o.exports)
}
return e[n].exports
}
if ("function" == typeof __nr_require)
return __nr_require;
for (var o = 0; o < n.length; o++)
r(n[o]);
return r
}({1:[function(t, e) {
function n(t, e, n) {
n || (n = {});
for (var r = o[t], a = r && r.length || 0, s = n[i] || (n[i] = {}), u = 0; a > u; u++)
r[u].apply(s, e);
return s
}
function r(t, e) {
var n = o[t] || (o[t] = []);
n.push(e)
}
var o = {}, i = "nr@context";
e.exports = {on: r, emit: n}
}, {}], 2:[function(t) {
function e(t, e, n, i, s) {
return u ? u -= 1 : r("err", [s || new UncaughtException(t, e, n)]), "function" == typeof a ? a.apply(this, o(arguments)) : !1
}
function UncaughtException(t, e, n) {
this.message = t || "Uncaughterrorwithnoadditionalinformation", this.sourceURL = e, this.line = n
}
function n(t) {
r("err", [t, (new Date).getTime()])
}
var r = t("handle"), o = t(6), i = t(5), a = window.onerror, s = !1, u = 0;
t("loader").features.push("err"), window.onerror = e, NREUM.noticeError = n;
try {
throw new Error
} catch (d) {
"stack"in d && (t(1), t(2), "addEventListener"in window && t(3), window.XMLHttpRequest && XMLHttpRequest.prototype && XMLHttpRequest.prototype.addEventListener && t(4), s = !0)
}
i.on("fn-start", function() {
s && (u += 1)
}), i.on("fn-err", function(t, e, r) {
s && (this.thrown = !0, n(r))
}), i.on("fn-end", function() {
s && !this.thrown && u > 0 && (u -= 1)
}), i.on("internal-error", function(t) {
r("ierr", [t, (new Date).getTime(), !0])
})
}, {1:5, 2:4, 3:3, 4:6, 5:1, 6:14, handle:"D5DuLP", loader:"G9z0Bl"}], 3:[function(t) {
function e(t) {
r.inPlace(t, ["addEventListener", "removeEventListener"], "-", n)
}
function n(t) {
return t[1]
}
var r = t(1), o = (t(3), t(2));
if (e(window), "getPrototypeOf"in Object) {
for (var i = document; i && !i.hasOwnProperty("addEventListener"); )
i = Object.getPrototypeOf(i);
i && e(i);
for (var a = XMLHttpRequest.prototype; a && !a.hasOwnProperty("addEventListener"); )
a = Object.getPrototypeOf(a);
a && e(a)
} else
XMLHttpRequest.prototype.hasOwnProperty("addEventListener") && e(XMLHttpRequest.prototype);
o.on("addEventListener-start", function(t) {
if (t[1]) {
var e = t[1];
"function" == typeof e ? this.wrapped = e["nr@wrapped"] ? t[1] = e["nr@wrapped"] : e["nr@wrapped"] = t[1] = r(e, "fn-") : "function" == typeof e.handleEvent && r.inPlace(e, ["handleEvent"], "fn-")
}
}), o.on("removeEventListener-start", function(t) {
var e = this.wrapped;
e && (t[1] = e)
})
}, {1:15, 2:1, 3:14}], 4:[function(t) {
var e = (t(3), t(1)), n = t(2);
e.inPlace(window, ["requestAnimationFrame", "mozRequestAnimationFrame", "webkitRequestAnimationFrame", "msRequestAnimationFrame"], "raf-"), n.on("raf-start", function(t) {
t[0] = e(t[0], "fn-")
})
}, {1:15, 2:1, 3:14}], 5:[function(t) {
function e(t) {
var e = t[0];
"string" == typeof e && (e = new Function(e)), t[0] = n(e, "fn-")
}
var n = (t(3), t(1)), r = t(2);
n.inPlace(window, ["setTimeout", "setInterval", "setImmediate"], "setTimer-"), r.on("setTimer-start", e)
}, {1:15, 2:1, 3:14}], 6:[function(t) {
function e() {
o.inPlace(this, s, "fn-")
}
function n(t, e) {
o.inPlace(e, ["onreadystatechange"], "fn-")
}
function r(t, e) {
return e
}
var o = t(1), i = t(2), a = window.XMLHttpRequest, s = ["onload", "onerror", "onabort", "onloadstart", "onloadend", "onprogress", "ontimeout"];
window.XMLHttpRequest = function(t) {
var n = new a(t);
try {
i.emit("new-xhr", [], n), o.inPlace(n, ["addEventListener", "removeEventListener"], "-", function(t, e) {
return e
}), n.addEventListener("readystatechange", e, !1)
} catch (r) {
try {
i.emit("internal-error", r)
} catch (s) {
}
}
return n
}, 
window.XMLHttpRequest.prototype = a.prototype, o.inPlace(XMLHttpRequest.prototype, ["open", "send"], "-xhr-", r), i.on("send-xhr-start", n), i.on("open-xhr-start", n)
}, {1:15, 2:1}], 7:[function(t){function e(){function e(t){if ("string" == typeof t && t.length)return t.length; if ("object" != typeof t)return void 0; if ("undefined" != typeof ArrayBuffer && t instanceof ArrayBuffer && t.byteLength)return t.byteLength; if ("undefined" != typeof Blob && t instanceof Blob && t.size)return t.size; if ("undefined" != typeof FormData && t instanceof FormData)return void 0; try{return JSON.stringify(t).length} catch (e){return void 0}}function n(t){var n = this.params, r = this.metrics; if (!this.ended){this.ended = !0; for (var i = 0; u > i; i++)t.removeEventListener(s[i], this.listener, !1); if (!n.aborted){if (r.duration = (new Date).getTime() - this.startTime, 4 === t.readyState){n.status = t.status; var a = t.responseType, d = "arraybuffer" === a || "blob" === a || "json" === a?t.response:t.responseText, f = e(d); if (f && (r.rxSize = f), this.sameOrigin){var c = t.getResponseHeader("X-NewRelic-App-Data"); c && (n.cat = c.split(",
").pop())}}else n.status=0;r.cbTime=this.cbTime,o("xhr",[n,r])}}}function r(t,e){var n=i(e),r=t.params;r.host=n.hostname+": "+n.port,r.pathname=n.pathname,t.sameOrigin=n.sameOrigin}t("loader").features.push("xhr");var o=t("handle"),i=t(1),a=t(5),s=["load","error","abort","timeout"],u=s.length,d=t(2);t(3),t(4),a.on("new - xhr",function(){this.totalCbs=0,this.called=0,this.cbTime=0,this.end=n,this.ended=!1,this.xhrGuids={}}),a.on("open - xhr - start",function(t){this.params={method:t[0]},r(this,t[1]),this.metrics={}}),a.on("open - xhr - end",function(t,e){"loader_config"in NREUM&&"xpid"in NREUM.loader_config&&this.sameOrigin&&e.setRequestHeader("X - NewRelic - ID",NREUM.loader_config.xpid)}),a.on("send - xhr - start",function(t,n){var r=this.metrics,o=t[0],i=this;if(r&&o){var d=e(o);d&&(r.txSize=d)}this.startTime=(new Date).getTime(),this.listener=function(t){try{"abort"===t.type&&(i.params.aborted=!0),("load"!==t.type||i.called===i.totalCbs&&(i.onloadCalled||"function"!=typeof n.onload))&&i.end(n)}catch(e){try{a.emit("internal - error",e)}catch(r){}}};for(var f=0;u>f;f++)n.addEventListener(s[f],this.listener,!1)}),a.on("xhr - cb - time",function(t,e,n){this.cbTime+=t,e?this.onloadCalled=!0:this.called+=1,this.called!==this.totalCbs||!this.onloadCalled&&"function"==typeof n.onload||this.end(n)}),a.on("xhr - load - added",function(t,e){var n=""+d(t)+!!e;this.xhrGuids&&!this.xhrGuids[n]&&(this.xhrGuids[n]=!0,this.totalCbs+=1)}),a.on("xhr - load - removed",function(t,e){var n=""+d(t)+!!e;this.xhrGuids&&this.xhrGuids[n]&&(delete this.xhrGuids[n],this.totalCbs-=1)}),a.on("addEventListener - end",function(t,e){e instanceof XMLHttpRequest&&"load"===t[0]&&a.emit("xhr - load - added",[t[1],t[2]],e)}),a.on("removeEventListener - end",function(t,e){e instanceof XMLHttpRequest&&"load"===t[0]&&a.emit("xhr - load - removed",[t[1],t[2]],e)}),a.on("fn - start",function(t,e,n){e instanceof XMLHttpRequest&&("onload"===n&&(this.onload=!0),("load"===(t[0]&&t[0].type)||this.onload)&&(this.xhrCbStart=(new Date).getTime()))}),a.on("fn - end",function(t,e){this.xhrCbStart&&a.emit("xhr - cb - time",[(new Date).getTime()-this.xhrCbStart,this.onload,e],e)})}window.XMLHttpRequest&&XMLHttpRequest.prototype&&XMLHttpRequest.prototype.addEventListener&&!/CriOS/.test(navigator.userAgent)&&e()},{1:8,2:11,3:3,4:6,5:1,handle:"D5DuLP",loader:"G9z0Bl"}],8:[function(t,e){e.exports=function(t){var e=document.createElement("a"),n=window.location,r={};e.href=t,r.port=e.port;var o=e.href.split(": //");return!r.port&&o[1]&&(r.port=o[1].split("/")[0].split(": ")[1]),r.port&&"0"!==r.port||(r.port="https"===o[0]?"443":"80"),r.hostname=e.hostname||n.hostname,r.pathname=e.pathname,"/"!==r.pathname.charAt(0)&&(r.pathname="/"+r.pathname),r.sameOrigin=!e.hostname||e.hostname===document.domain&&e.port===n.port&&e.protocol===n.protocol,r}},{}],handle:[function(t,e){e.exports=t("D5DuLP")},{}],D5DuLP:[function(t,e){function n(t,e){var n=r[t];return n?n.apply(this,e):(o[t]||(o[t]=[]),void o[t].push(e))}var r={},o={};e.exports=n,n.queues=o,n.handlers=r},{}],11:[function(t,e){function n(t){if(!t||"object"!=typeof t&&"function"!=typeof t)return-1;if(t===window)return 0;if(o.call(t,"__nr"))return t.__nr;try{return Object.defineProperty(t,"__nr",{value:r,writable:!0,enumerable:!1}),r}catch(e){return t.__nr=r,r}finally{r+=1}}var r=1,o=Object.prototype.hasOwnProperty;e.exports=n},{}],loader:[function(t,e){e.exports=t("G9z0Bl")},{}],G9z0Bl:[function(t,e){function n(){var t=p.info=NREUM.info;if(t&&t.agent&&t.licenseKey&&t.applicationID&&u&&u.body){p.proto="https"===c.split(": ")[0]||t.sslForHttp?"https: //":"http: //",a("mark",["onload",i()]);var e=u.createElement("script");e.src=p.proto+t.agent,u.body.appendChild(e)}}function r(){"complete"===u.readyState&&o()}function o(){a("mark",["domContent",i()])}function i(){return(new Date).getTime()}var a=t("handle"),s=window,u=s.document,d="addEventListener",f="attachEvent",c=(""+location).split("?")[0],p=e.exports={offset:i(),origin:c,features:[]};u[d]?(u[d]("DOMContentLoaded",o,!1),s[d]("load",n,!1)):(u[f]("onreadystatechange",r),s[f]("onload",n)),a("mark",["firstbyte",i()])},{handle:"D5DuLP"}],14:[function(t,e){function n(t,e,n){e||(e=0),"undefined"==typeof n&&(n=t?t.length:0);for(var r=-1,o=n-e||0,i=Array(0>o?0:o);++r<o;)i[r]=t[e+r];return i}e.exports=n},{}],15:[function(t,e){function n(t,e,r,s){function nrWrapper(){try{var n,a=u(arguments),d=this,f=r&&r(a,d)||{}}catch(c){i([c,"",[a,d,s],f])}o(e+"start",[a,d,s],f);try{return n=t.apply(d,a)}catch(p){throw o(e+"err",[a,d,p],f),p}finally{o(e+"end",[a,d,n],f)}}return a(t)?t:(e||(e=""),nrWrapper[n.flag]=!0,nrWrapper)}function r(t,e,r,o){r||(r="");var i,s,u,d="-"===r.charAt(0);for(u=0;u<e.length;u++)s=e[u],i=t[s],a(i)||(t[s]=n(i,d?s+r:r,o,s,t))}function o(t,e,n){try{s.emit(t,e,n)}catch(r){i([r,t,e,n])}}function i(t){try{s.emit("internal-error",t)}catch(e){}}function a(t){return!(t&&"function"==typeof t&&t.apply&&!t[n.flag])}var s=t(1),u=t(2);e.exports=n,n.inPlace=r,n.flag="nr@wrapper"},{1:1,2:14}]},{},["G9z0Bl",2,7]);
==================================================
  • No servidor ativo, estou usando o New Relic para monitorar o desempenho do site.

  • Quando a New Relic é ativada, ele adiciona esse código de script no início da resposta ajax do modelo de email, o que causa sintaxe JSON inválida e, por isso, para de processar o modelo e não carrega o conteúdo do modelo.

  • Procurei a solução e uma maneira possível é que, se desabilitarmos o New Relic, os modelos de email funcionarão bem e, assim que concluirmos as alterações, poderemos reativá-la novamente.

obrigado


7

A função que carrega o modelo de email é

Mage_Adminhtml_System_Email_TemplateController::defaultTemplateAction()

Você pode conectar-se a um evento (predispatch & co) e executar:

newrelic_disable_autorum ( )

Isso informa à nova relíquia que esta solicitação não terá o RUM ativado.

Outra opção é desativar o RUM para todo o administrador (realmente fácil se você tiver um administrador em um nó da Web separado, módulo simples com um evento para a área de administração, etc).


Isso faz sentido, também tenho o Newrelic instalado no servidor. Eu não tinha ideia de que poderia atrapalhar o site. Testarei sua solução em breve. Obrigado
Bractar
Ao utilizar nosso site, você reconhece que leu e compreendeu nossa Política de Cookies e nossa Política de Privacidade.
Licensed under cc by-sa 3.0 with attribution required.