2

enter image description here

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

2
  • Have you got solution ?
    – Pawan
    Commented Jul 20, 2017 at 3:32
  • @PawanKParmar - no I haven't
    – Aks
    Commented Jul 20, 2017 at 8:28

1 Answer 1

4
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:

enter image description here

9
  • app/design/frontend/rwd/default/template/email/order/items/order/default.phtml as you suggested, I have added this code in this file before getqtyordered()<?php $_product = Mage::getModel('catalog/product')->loadByAttribute('sku',$_item->getSku()); ?> <td class="cell-content align-center"><?php echo $_product->getCustom(); ?></td> <td class="cell-content align-center"><?php echo $product->getAttributeText('hsn_type');?> </td> <td class="cell-content align-center"><?php echo $_item->getQtyOrdered()*1 ?></td> it's not working, am i doing something wrong
    – Aks
    Commented Jul 21, 2017 at 8:47
  • @Aks, Why you are putting <td class="cell-content align-center"><?php echo $_product->getCustom(); ?></td> in your code ? if attribute code id 'hsn_type' then you can use <td class="cell-content align-center"><?php echo $_product->getHsnType(); ?>.
    – Pawan
    Commented Jul 21, 2017 at 16:40
  • @Aks, what is type of your custom attribute ?
    – Pawan
    Commented Jul 21, 2017 at 16:45
  • Attribute Code (hsn_type) and Product type - simple product
    – Aks
    Commented Jul 21, 2017 at 17:03
  • I am asking about attribute type e.g text or drop-down or multi-select
    – Pawan
    Commented Jul 21, 2017 at 17:14

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.