Use of WeightUnit for Magento

WeightUnit for Magento introduces a Weight Unit to the Catalog Products which is usable for automatic weight conversion to a configured Store Weight Unit:


In System » Configuration » General » Locale Options an additional option Weight Unit is introduced, which allows to select the Weight Unit for the Store:

This option allows to disable the automatic Weight Conversion for the store (set it to – Disabled –) or set Kilogram or Pound as the Stores Weight Unit. Together with the Weight Unit set for the individual Products, this will result in automatic weight conversion of each Product to the Stores Weight Unit set here for all Quote Items and Order Items. The resulting shipping weights will also be in this Weight Unit.

After initial setup the message For Weight Conversion to work please select the default Weight Unit in Catalog Attribute »weight_unit« will be shown, which indicates the the Catalog Attribute weight_unit requires adding of the Weight Units used on the Products and selection of the default Weight Unit there.

Use Catalog » Attributes » Manage Attributes to prepare the Attribute for use on your Products. This is the Attribute configuration in case during initial installation or later the related Attribute is lost, the Attribute Name weight_unit is mandatory:

To add individual Weight Units for use with your Products use Manage Label/Options to add them:

  • Use the SI Measurement Unit for the weight at the beginning of the label, any description is required to be separated by a space from the SI Unit (to allow the extension to identify the SI unit of the option). For example kg (Kilogram).
  • SI Units supported for these options are metric weights in mg, g, kg, and imperial weights in lb (or lbs), oz.
  • Select the default weight unit applicable to all Products (if not set in the Product or for new Products) by selecting Is Default for the default Weight Unit option.



Add the Catalog Attribute »weight_unit« to the Catalog Attribute Sets

To use the Weight Unit for the Catalog Products you need to add the Attribute weight_unit to the Attribute Sets where you need it, using Catalog » Attributes » Manage Attribute Sets:



After the initial installation of the WeightUnit extension the Stores Products will not have any value set for the weight_unit Catalog Attribute. For such products the default value defined in the Catalog Attribute is used for the Product.

In the Configuration Option for the Weight Unit, with the related Catalog Attribute fully configured, there will be the following Options available:
The following functions allow to set or reset the Weight Unit for all Products:

Update Products to default Weight Unit

Sets the default Weight Unit to all Products which have currently no Weight Unit set, without any conversion of the Product Weight.

Reset Products to default Weight Unit

Resets all Products (regardless if a Weight Unit is set or not) to the default Weight Unit, without any conversion of the Product Weight.

Some Shipment Methods allow to set the Product Weigh Unit. For these Shipment Methods you need to set the Weight Unit to the same Weight Unit the Store is set to. The Weight conversion from the Product Weight Unit to the Store Weight Unit is done by this extension.

To show the Product Weight on the Product Page use the following Widget Block:

catalog/product/view.phtml

<?php echo $this->getLayout()->createBlock('weightunit/widget_weight')->toHtml() ?>

The above Widget Code uses the Weight Unit of the current store, to get the Weight shown in any other arbitrary Weight Unit use:

catalog/product/view.phtml

<?php echo $this->getLayout()->createBlock('weightunit/widget_weight')->setWeightUnit('POUND')->toHtml() ?>

The Weight Unit codes used here must be in accordance with the constants used in the conversion library of /lib/Zend/Measure/Weight.php:
GRAM KILOGRAM TON POUND …

The related template file for this Widget is located in weightunit/widget/weight.phtml of the default template package.