How do you integrate the unit of measurement of a product (e.g. pieces, m, sq m, liters, etc.) into the order confirmation in the "Quantity" (Qty) column? First, let's take a look at which file is responsible for displaying the ordered products:
We find it here in the template file \app\design\frontend\YOURPACKAGE\YOURTEMPLATE\template\email\order\items\order\default.phtml (or in the base package / default template if no customizations have yet been made to the standard installation).
The unit of measurement has been implemented here via a dropdown attribute called 'einheit'. We therefore first need to retrieve the value of this attribute, ideally without having to reload the entire product. To do this, we first retrieve the option value using the getAttributeRawValue() method of the catalog/product resource model (we use the singleton method to check whether the object is already available in the cache, making the process faster):
$optionValue = Mage::getResourceSingleton('catalog/product')->getAttributeRawValue($_item->getProductId(),'einheit_mah',0);
Next, we want to know which option text corresponds to the option value. To do this, we assign the option value we retrieved to the catalog/product model:
$temp_product = Mage::getSingleton('catalog/product')->setStoreId(0)->setData('einheit',$optionValue);
and resolve it using getAttributeText():
$optionText = $temp_product->getAttributeText('einheit');
We can then insert the option text anywhere we like, for example, after displaying the ordered quantity of the respective product:
<td class="cell-content align-center" align="center"><?php echo $_item->getQtyOrdered()*1; echo $optionText; ?></td>
And that's it. Tested with Magento CE 1.9.2.4.
