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

  • Have you got solution ? – Pawan Jul 20 '17 at 3:32
  • @PawanKParmar - no I haven't – Aks Jul 20 '17 at 8:28
3
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

  • 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 Jul 21 '17 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 Jul 21 '17 at 16:40
  • @Aks, what is type of your custom attribute ? – Pawan Jul 21 '17 at 16:45
  • Attribute Code (hsn_type) and Product type - simple product – Aks Jul 21 '17 at 17:03
  • I am asking about attribute type e.g text or drop-down or multi-select – Pawan Jul 21 '17 at 17:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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