$product_load = Mage::getModel('catalog/product')->loadByAttribute
('sku', $_item->getSku(), array('size'));
$productmodel = Mage::getModel('catalog/product');
$attrib = $productmodel->getResource()->getAttribute('size');
if ($attrib->usesSource()) {
echo 'Size ' . $attrib->getSource()->getOptionText
($product_load->getData('size'));
}
Thursday, February 6, 2014
Magento: Add custom attribute to order template and get option value by ID
Today I dealt with an issue where the value of an attribute was not showing up on the order email. To solve this, I had to get the option ID of the attribute and from there get the option value. This is my code section I added to template/email/order/items/order/default.phtml :
Labels:
magento
Subscribe to:
Post Comments (Atom)
"Thanks for sharing, nice post.
ReplyDeletei follow you hope you could visit me here and follow me too,, thanks."
Magentocommerce - Magento Development
hi! Thanks for the tutoril. However, I tend to use extensions for such things. For order attributes I'm using that one http://amasty.com/order-attributes.html
ReplyDeleteThanks for sharing this short and simple tutorial. I would recommend to use a full-fledged Checkout Fields Manager in order to add custom order fields to the checkout page. Try FME Additional Checkout Fields Magento Extension to add any type of fields to any section of the checkout page.
ReplyDelete