Note that there are some explanatory texts on larger screens.

plurals
  1. POMagento email template: Block template inheritance broken
    primarykey
    data
    text
    <p><strong>Problem</strong></p> <p>When I try to add a block into my transactional email template in the following manner:</p> <p><code>{{block type='core/template' area='frontend' template='invent/baskettimer/email_items.phtml' record=$record}}</code></p> <p>I get the following error, and nothing is rendered.</p> <p><code>CRIT (2): Not valid template file:frontend/base/default/template/invent/baskettimer/email_items.phtml</code></p> <p><strong>Troubleshooting</strong></p> <ul> <li>Normally this warning points to a typo which is breaking the inheritance but I have quadruple checked and this should work.</li> <li>I then copied the file into the base and did a test, it rendered correctly.</li> <li>Create a custom block and set the template, same error is displayed.</li> </ul> <p><strong>Theory</strong></p> <p>To me it seems template inheritance is broken / not implemented for emails, so it is always looking in base, I cannot put my templates there so I am not sure how to call them.</p> <p><strong>Possible workarounds</strong></p> <ul> <li>Render the block to html then send it to as a variable to render, problem with this is I am sending the emails from Model level and am having a hard time pre rendering the block, even with a helper.</li> <li>Render the data using a method, don't really want to do this as it is message / against MVC.</li> </ul> <p>Any help is much appreciated. </p> <hr> <p><strong>Bounty update</strong></p> <p>So I have traced down the problem, it is probably an easy solution now.</p> <p>The problem is that I am calling it from a cronjob does not have the correct store view, it is fairly easy to replicate similar situation by using a shell script, then changing the _appCode to null.</p> <pre><code>&lt;?php require_once 'abstract.php'; class Mage_Shell_Shell extends Mage_Shell_Abstract { protected $_appCode = ''; // works - remove to not work /** * Run script * */ public function run() { Mage::getModel('invent_baskettimer/email')-&gt;sendJob(); } } $shell = new Mage_Shell_Shell(); $shell-&gt;run(); </code></pre> <p>So basically the question has become:</p> <p><strong>How do I call a <code>block-&gt;toHtml()</code> regardless of store view?</strong></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload