I have a template, which is included in the transactional email using this code:

{{block type='core/template' area='frontend' template='myname_mymodule/pdffile.phtml' order=$order}}

and in the pdffile.phtml file i have:

$pdf  =  new Namespace_Module_PdfController();

I get a fatal error with class not found. Can someone help with this ? thx

  • as marius said you can't. and if you want to instantiate controller you need to call require_once before instantiate controller as controller is not auto loaded by default. – Minesh Patel May 25 '16 at 10:35
  • @MineshPatel. You can actually instantiate controllers, but it's a really bad idea. Alan Storm explains it how in here: magento.stackexchange.com/a/8751/146 – Marius May 25 '16 at 10:39
  • yes @Marius. Business logic should be in model and not in controller files. – Minesh Patel May 25 '16 at 10:43

you should never instantiate controllers inside template.
Actually you should never instantiate controllers manually.
If you have a custom behavior, put it inside a model or a template and call it inside the controller and inside the template.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.