Pass custom variable / parameter from email template to phtml file

I am stuck in my custom code.

I want to pass a user variable from an email template to a pthml file.

Edit file

Application / Code / Local / Mage / Sales / Model / Order.php

in this function:

public function sendNewOrderEmail()
  {

--- default code start ----
$mailer->setTemplateParams(array(
                'order'        => $this,
                'test'        => 'XXXXX',
                'billing'      => $this->getBillingAddress(),
                'payment_html' => $paymentBlockHtml
            )
        );
--- default code end ----
}

and then I put this code in the email template of the new order:

{{layout handle="sales_email_order_items" order=$order  test=$test}}

template file located here:

Applications / locale / en_US / template / email / sales / order_new.html

and I'm trying to get a test variable here:

application / design / interface / default / default / template / email / order / product / order / default.phtml

like this: $test = $this->getItem()->getTest()

but it will not work. Please let me know where I am going wrong? or what needs to be done to access this variable in the phtml file?

+4
2

, "test" Mage_Sales_Block_Order_Email_Items, tempalte "email/order/items.phtml".

, :

<?php $test = $this->getTest(); // or $this->getData('test') ?>

.

. , $mailer- > setTemplateParams(); :

//$this = current order if you are in Mage_Sales_Model_Order
foreach ($this->getAllVisibleItems() as $item) {
    $item->setData('test', 'test_value_10');
}
+2

{{var test}}

@

+2

All Articles