Magento: Add product/item attributes in order and invoice emails
I will show you how to add extra product attribute values, along with order item options and custom options in order emails and invoice emails.
Here is the code that should work for order and invoice emails to get additional PRODUCT ATTRIBUTES displayed:
For adding Product attributes to ORDER emails, you need to change in:app/design/frontend/base/default/template/email/order/items/order/default.phtml
For adding Product attributes to INVOICE emails, you need to change in:
app/design/frontend/base/default/template/email/order/items/invoice/default.phtml
$productId = $_item->getProduct()->getId(); //for order emails //$productId = $_item->getProductId(); //for invoice emails $product = Mage::getModel('catalog/product')->load($productId); $attributes = $product->getAttributes(); //Get a list of all PRODUCT ATTRIBUTES you want to show in this array... $dispAttribs = array('attribute1', 'attribute2', 'attribute3'); foreach ($attributes as $attribute) { $attributeCode = $attribute->getAttributeCode(); if(!in_array($attributeCode, $dispAttribs)) continue; $label = $attribute->getFrontend()->getLabel($product); $value = $attribute->getFrontend()->getValue($product); echo "<strong>" . $label . ":</strong> " . $value; }
or if you want to add only one attribute value like dropdown
$_prod = Mage::getModel('catalog/product')->loadByAttribute('sku',$this->getSku($_item)); echo $attribute_value = $_prod->getAttributeText('attribute_code');
For displaying CUSTOM OPTIONS and/or ITEM OPTIONS from the item, use this:
foreach($this->getItemOptions() as $opt) { if(isset($opt['option_id'])) { //for CUSTOM OPTIONS echo "" . $opt['label'] . ": ". $opt['option_value'] . ""; } else { //for ITEM OPTIONS echo "" . $opt['label'] . ": ". $opt['value'] . ""; } }
Please support us, Like us on Facebook.
Subscribe to:
Post Comments (Atom)
Yes! Finally something about cialis genérico canada.
ReplyDelete