Question

I would like to add a unit of measurement to my magento front end additional information. At the moment it is currently:

  • Length: 34
  • Height: 50
  • Weight: 13

The customer has no idea if it is centimeters or meters etc.

How can I change it to: - Length: 34cm - Height: 50cm - Weight: 13g

or

  • Length (cm): 34
  • Height (cm): 50
  • Weight (grams): 13

The first option is preferable.

This is the URL to an example: http://creativeinfusion.com.au/shop/beaded-square-offering-box-xsmall-black-red-green-flowers-2248

Thanks,

Was it helpful?

Solution

As you already know that attribute Unit is fixed. you can change attribute label from Manage Attribute Section in admin like:

Length ==  Length (cm)
Height ==  Height (cm)
Weight ==  Weight (grams)

if you want in this format - Length: 34cm - Height: 50cm - Weight: 13g

For this In current theme you have to edit template/catalog/product/view/attributes.phtml file.
In Attribute file pls replace the following code:

<?php foreach ($_additional as $_data):

        switch($_data['code']) {
            case 'height':
            case 'length':
                $value = $_helper->productAttribute($_product, $_data['value'], $_data['code']).'cm';
            break;      
            case 'weight':          
                $value = $_helper->productAttribute($_product, $_data['value'], $_data['code']).'g';
            break;
            default:            
                $value = $_helper->productAttribute($_product, $_data['value'], $_data['code']);
            break;              
        }
    ?>
        <tr>
            <th class="label"><?php echo $this->htmlEscape($this->__($_data['label'])) ?></th>
            <td class="data"><?php echo $value; ?></td>
        </tr>
    <?php endforeach; ?>

Please Check sure you have used same code for attribute, or change accordinlgy.

Hope this help !!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top