Once the products and SKUs have fractional units enabled, as outlined in the Enabling Fractional Units in Products and SKUs section, you can set the units in which they can be sold by specifying their UnitOfMeasure.

You can retrieve the UnitOfMeasure using the UnitOfMeasureDroplet, as described in the Guide to Setting Up a Store, or by defining and configuring fractional quantities and units of measure as described in the next sections.

For additional detail on all of the classes described in this section, refer to the ATG Platform API Reference.

Unit of Measure Configuration Files

The unitsOfMeasure values are configured in a configuration file, which identifies the types of measurement (for example liters, kilograms, etc.) and its values. The unitsOfMeasure values can be one of the following types:

Configure the options and increments in the UnitOfMeasure configuration file for the specific unit of measure. By default, the PoundsUnitOfMeasure and the GallonsUnitOfMeasure are configured to be options types. For example:

$class=atg.commerce.units.UnitsOfMeasure

type=options
options= \
  0.25=oneQuarter, \
  0.5=oneHalf, \
  0.75=threeQuarters

The KilogramsUnitOfMeasure and LitersUnitOfMeasure are configured to be increment types. For example:

$class=atg.commerce.units.UnitOfMeasure

type=increment
increment=0.1

By default, the units of measures provided are:

Unit of Measure

Type

Options

Increments

Pounds

Options

0.25 = ¼ pound
0.5 = ½ pound
0.75 = ¾ pound

N/A

Kilograms

Increments

N/A

0.1 where 0.1 = 100gm

Gallons

Options

0.25 = 1 quart
0.5 = 2 quarts
0.75 = 3 quarts

N/A

Liters

Increments

N/A

0.1 where 0.1 = 100ml

UnitOfMeasureManager Class

The UnitOfMeasureManager class is a manager class that returns a unit of measure’s configuration once the configuration files have been implemented. The UnitOfMeasureManager class maps the unit of measure configurations identified by the configuration files using the unitsOfMeasure ServiceMap, where the value of the units are used as keys in a service map configured in CatalogTools. The ServiceMap allows you to identify the fractional quantities that have been configured. For example:

## ServiceMap of unitOfMeeasure to UnitOfMeasure
unitsOfMeasure= \
  pounds=PoundsUnitOfMeasure, \
  kilograms=KilogramsUnitOfMeasure, \
  gallons=GallonsUnitOfMeasure, \
  liters=LitersUnitOfMeasure

Note that when new units of measure are added, you must update the ServiceMap.

UnitOfMeasure Class

The UnitOfMeasure class gets and sets the configuration of a unit of measure. It identifies the type of fractional unit used, such as options or increments, and the corresponding options (including the values and labels) or increments of the unit to be used. It also returns an ordered list of UnitOfMeasureOption beans. The list is ordered in unit value by increasing order. The unit labels can be localized when the il8n parameter is set to true.

The UnitOfMeasure class can be used to set localization when rendering products and SKUs in a product detail page’s input fields and data by calling the il8n parameter. The UnitOfMeasureResources.properties file contains the il8n parameter, which is a boolean property that localizes unit labels when set to true.

Use this class if you are not using the UnitOfMeasureDroplet and want the value for a specific unit of measure. This class also returns options based on locale.

UnitOfMeasureOption Class

The UnitOfMeasureOption class represents the unit of measure values and their associated labels. For example, 0.25 could be labeled as a “quarter gallon”. This class allows you to set unit values, labels and increments as well as identify if the labels should be localized.


Copyright © 1997, 2016 Oracle and/or its affiliates. All rights reserved. Legal Notices