Add unit of measurement to magento front end

Add unit of measurement to magento front end

August 15, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Add unit of measurement to magento front end

Adding Units of Measurement to Magento Front End

When working with e-commerce platforms like Magento, it’s essential to provide customers with complete and accurate product information. This includes specifying units of measurement for dimensions such as length, height, and weight. Currently, your Magento store lists these measurements without any context:

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

Customers are left guessing whether the “Length” is in centimeters or meters, which can lead to confusion and potential mistakes during purchasing decisions.

To resolve this issue, you can easily add units of measurement to your Magento front end. The preferred format is:

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

Step-by-Step Guide: Adding Units of Measurement

1. Check Your Product Attribute Settings

First, log in to your Magento admin panel and navigate to “Catalog” > “Attributes”. Find the attributes for length, height, and weight (likely named “length”, “height”, and “weight”).

In each attribute’s settings, ensure that the input type is set to “text”. If it isn’t, change it accordingly.

2. Modify Your Product Templates

The next step involves modifying your product detail page templates. These are typically located in the app/design/frontend/your_package/your_theme/template/catalog/product/view.phtml file or similar.

Open this file and find where the dimensions are displayed. It should be something like:

<p class="price-info"><?php echo $block->getProductDimension() ?></p>

3. Add Units of Measurement

You need to modify how the product dimension is retrieved and formatted. Open your app/code/core/Mage/Catalog/Block/Product/View.php file (or similar, depending on your version) and find the getProductDimension() method.

Modify this method as follows:

public function getProductDimension()
{
    $dimensions = array();
    if ($this->hasLength()) {
        $dimensions[] = Mage::helper('core')->__('%s: %d%s', $this->_lengthLabel, $this->getLength(), 'cm');
    }
    // Similarly add height and weight
}

Replace 'cm' with the appropriate unit for each dimension.

4. Compile Your Magento Store

After making these changes, you need to compile your Magento store for the modifications to take effect. Go to “System” > “Tools” > “Compilation”, then click on “Run Compilation Process”.

Conclusion

Adding units of measurement is a simple yet crucial step in enhancing user experience and reducing potential customer confusion. By following this guide, you can easily modify your Magento store’s front end to display dimensions with their respective units.

Remember that it’s important to keep your Magento version up-to-date for optimal performance and security. For more detailed guides on customizing your e-commerce platform, consider visiting Laravel Company for expert insights from a leading web development agency.

Catalog Themes Admin Configuration

Our network