How to add new column and custom attribute in order email template in Magento 1.9.3?
-
10-10-2020 - |
Question
In this new order email.
I want to add a column in this table where i want to show a custom product attribute..
Please tell me how can i add column inside the new Order confirmation email template so it will show another column and attribute
already tried editing
app/design/frontend/template/default/template/email/order/items/order/default.phtml
app/design/frontend/base/default/template/email/order/items/order/default.phtml
and template files in app/locale
folder.
Thanks
Solution
Consideration:code of custom attribute is custom
Note: Please do not edit core files, Copy below files to your Theme
First we need to add a column to template:
file path:app\design\frontend\rwd\default\template\email\order\items.phtml
add below code before Qty th
<th class="cell-name align-center">
<?php echo $this->__('Custom'); ?>
</th>
Now we need to get value of custom attribute.file that is responsible for getting all attribute values is:
app\design\frontend\rwd\default\template\email\order\items\order\default.phtml
In above file when you log $_item, it will default not having value of custom attribute.So what we need is to load product and get value of product custom attribute. for that you need to add below code before Qty td:
<?php $_product = Mage::getModel('catalog/product')->loadByAttribute('sku',$_item->getSku()); ?>
//load product by sku
<td class="cell-content align-center"><?php echo $_product->getCustom(); ?></td>
//add td column with attribute value
Result: