1

In the email templating syntax. Is it possible to assign a return value of a magento helper to a variable?

For example this would be perfect:

{{var myVar = helper(myhelper).helperMethod }}

i.e. i want to assign the return value of a helper method to a variable in the template.

5

You can include the output of any block into the shipping email via the following:

{{block type="yourcustom/shippingblock" template="path/to/your/template.phtml"}}

IIRC your block must extend Mage_Core_Block_Template. To get ahold of the current shipment information in your block use the following:

$shipment = Mage::registry('current_shipment');

Since patch SUPEE-6788 or Magento 1.9.2.2 block which are used in the email templates or in CMS pages need to be white listed. See How can i add block to whitelist?

| improve this answer | |
  • I'll leave this answer, but for some reason @axel's answer wasn't displaying here when I posted. – philwinkle Aug 29 '13 at 19:04
  • I think my question is missleading. I will edit the question to make it more clear – Marty Wallace Aug 30 '13 at 8:56
2

You can include blocks into the email templates, using the standard CMS block code.

For example:

{{block type='core/template' area='frontend' template='email/my_email_block.phtml' order=$order shipment=$shipment }}

Then in the template file email/my_email_block.phtml

-> You can access the Shipment object by using $this->getShipment().
-> You can access the Order object by using $this->getOrder().

| improve this answer | |
  • Unfortunately i need it assigned to a template variable. – Marty Wallace Aug 29 '13 at 18:12
  • What do you mean assigned to a template variable? Can you provide what you've done so far (the methods you took to add the new property to the shipment object), and the intended output in the email? – Axel Aug 29 '13 at 18:14
  • I mean in the template there are a list of variables available using the syntax {{var theVariable}} later in the sendTransactional method of Mage_Core_Model_Email_Template these variables get passed. I need to access them at this point so it must be variable on the email template. – Marty Wallace Aug 29 '13 at 18:17

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.