Transactional email templating syntax - calling a helper or model method and assign to variable

magento.stackexchange https://magento.stackexchange.com/questions/7337

  •  16-10-2019
  •  | 
  •  

Question

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.

Was it helpful?

Solution

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?

OTHER TIPS

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().

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top