Add a non database attribute to order email

109 Views Asked by At

we have a single attribute which is shown on single product page. Attribut Name is lieferkW. For any order of a product i want to send the content of this attribute to our customers in the order email.

i dont want to save the content of this attribute in database. Do you have any solution for my problem?

2

There are 2 best solutions below

0
On

To include your custom attribute lieferkW in your sales order email, make these changes

1) Open \app\code\core\Mage\Sales\Model\Order.php

$customAttr = 'custom_value'; // the attribute "lieferkW" value
$mailer->setTemplateParams(array(
          'order'        => $this,
          'billing'      => $this->getBillingAddress(),
          'payment_html' => $paymentBlockHtml,
          'custom'       => $customAttr //your custom value here
      )
);

2) Now change the email template located at \app\locale\en_US\template\email\sales\order_new.html

You can access you variable here like

{{var custom}}

P.S. I advice not to make changes in the core files.

0
On

You can use other resources, like the session, the local storage, or a temporary file.

However, I would suggest that you should store this in the database and remove it when you send the email. You could have a table like this

temporary_attributes(id, userId, attribute, orderId)

insert it when you need it and remove it once you have sent the email.