How to display product unit of measurement on frontend (website) in Magento?

How to display product unit of measurement on frontend (website) in Magento?

September 22, 2026 · Illustrated author avatarBy Stefan Bogdanescu
How to display product unit of measurement on frontend (website) in Magento?

Displaying Product Unit of Measurement on Magento Frontend

As an e-commerce developer, you’ll often need to display product attributes like unit of measurement on your Magento store’s frontend. This guide will walk you through the process step-by-step.

Creating and Assigning the Attribute

Firstly, ensure that you have created the weight_unit attribute in your admin panel:

  1. Go to Catalog > Attributes > Manage Attributes.
  2. Click Add New Attribute at the top right corner.
  3. Fill in the required details such as name (Weight Unit), data type (Text), and other settings.
  4. Save the new attribute.

Next, assign this attribute to your products:

  1. Go to Catalog > Products.
  2. Select a product to edit or click Add New Product.
  3. In the Product Details section, find the Customizable Options tab.
  4. Click Add Attribute and select your weight_unit attribute from the list.

Displaying the Unit on Frontend

To display the unit of measurement on the product view page, you can use the following code snippet:

<?php echo $_product->getAttributeText('weight_unit'); ?>

Place this code within your product view template file (usually catalog/product/view.phtml).

However, if you’re still not seeing the attribute value properly displayed, ensure that:

  • You have assigned a valid unit value for each product.
  • The attribute is visible in the Catalog Input Type for Front-end field.

Alternative Methods

If the above method isn’t working as expected, consider these alternatives:

  1. Use a custom block: Create a new block and call it from your template using the getChildHtml function.

  2. Use an observer: You can create an event observer that triggers when the product is loaded and adds the unit to the view data.

  3. Use a plugin: Magento 2 plugins can be used to override or extend existing functionality, such as product load logic.

Conclusion

Displaying additional product attributes like unit of measurement requires careful configuration within the admin panel. Remember to assign the attribute to your products and ensure visibility settings are correct.

If you’re still facing issues, consider reaching out to a Magento development agency or checking our comprehensive guide on Magento customization services for expert assistance in implementing advanced frontend changes.

Catalog Themes Admin Configuration

Our network