0

I want to change the default SKU field inside the transactional email item field, to a custom attribute.

Therefore I need to edit the following file:

/app/design/frontend/theme/theme/template/email/order/items/order/default.phtml

I want to change the following value:

<?php echo $this->escapeHtml($this->getSku($_item)) ?>

My custom attribute value is "dpn" and it is named "DPN".

How can I change this?

I tried the following but that does not work:

<?php echo $this->escapeHtml($this->getDpn($_item)) ?>

1 Answer 1

0

You need to understand that calling $this->getSku() or $this->getDpn() is referring to a method that you can/could find in the related Block, in your case:

app\code\core\Mage\Sales\Block\Order\Email\Items\Default.php

in which you'll find the relevant getSku() method. You could in turn extend this class and add your getDpn() method, but I believe what you are trying to do it get a product's attribute.

If it's the case, you only have to do

<?php echo $this->escapeHtml($_item->getProduct()->getDpn()) ?>

But be aware that it might be costly because Magento will internally call app\code\core\Mage\Sales\Model\Order\Item.php:getProduct() which instantiates the given product.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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