ART#303 - What is inventory in ATG? How do we manage it?

Till now, we have understood that we need to have something to sell (basically a catalog). There are categories, products, SKUs etc. in a catalog.
Just like at any physical store,  an item may be In-Stock, Low-in-stock or simply out-of-stock, we have a similar concept in ATG known as Inventory.
Since the actual sellable entity in our framework in SKU, we need to have some inventory associated with it.
All the inventory is managed via /atg/commerce/inventory/InventoryRepository.
This repository deals with the inventory of all the SKUs of a website. Unless you have a repository-item of the item-descriptor "inventory" in the InventoryRepository, you cannot add the SKU to cart. And if you cant add it to cart, user cannot purchase it!

Adding a SKU Inventory 

With inventory playing a key role in commerce, we need to use the InventoryRepository to associate inventory data to a SKU.
Based on your type of implementation, there could be different ways of inserting data into your repository. The ways could be different, but data has to go into the InventoryRepository, which is pretty much easy and just like inserting data into any other repository. 
The InventoryRepository contains an item-descriptor called "inventory". This item-descriptor has a lot of property, three of which are most important. 

1. catalogRefId: This is the SKU-ID. If you have a sku in the catalog, then put the same ID here. The inventory will be mapped using this sku-id. 

2. stockLevel: This is the inventory level i.e. the quantity available for sale (or quantity in stock). This should hold a positive integer including zero (0). 

3. availabilityStatus: This is an enum which denotes the status of inventory. You might not use it in the code, but you have to specify the value in the repository-item.    
You can also add more values to this enum according to your implementation.
Possible values include:
I mostly find INSTOCK and OUTOFSTOCK handy, as i can use it directly in situations where i want to check if item is in-stock or out-of-stock.
Of course, we can always use the condition:

if((Integer)inventoryItem.getPropertyValue("stockLevel") <= 0) {
    -- do actions when item is out of stock
} else if ((Integer)inventoryItem.getPropertyValue("stockLevel") > 0) {
    -- do actions when item is in stock

But using the availabilityStatus, is more handy and readable.See below screenshot for details.

Now, we know which properties of item-descriptor "inventory" are important, and we know that we need to simply insert data into the repository.
Once the data is inserted into the InventoryRepository for a SKU, we can add it to cart.

Adding More Values to availabilityStatus
As we discussed above, we can add more values to the availabilityStatus property to inventory item-descriptor.
Suppose, we want to add  a new enum value "LIMITEDSTOCK", you can simply follow the below steps:-

Extend the xml-file for the InventoryRepository. XML file is located at

Extend the item-descriptor "inventory" using "append" xml-combination and add   the following:-

  • Provide a Resource Bundle. We will discuss this in next step.
  • Extend the existing property "availabilityStatus" using xml-combine="append". This is an OOTB enum property.
  • Add a new <option> for the enum. Provide a "resource" property and a "code" property. These property names should not be existing.
3. Add a ResourceBundle in your class-path. 
  • A Resource-Bundle is a properties file which is stored in you classpath [where you keep your JAVA files and packages] and not in your config-path
  • This is required to map the option "resource" value to the text "LIMITEDSTOCK".
  • The resourcebundle we provided will be stored in a Java Package at location,
  • Next,  add the following content in the file. [availabilityStatusLimitedStock=LIMITEDSTOCK]
Now, you also have LIMITEDSTOCK as a new availabilityStatus value.

Updating or Adding inventory of a SKU is same as adding any item to an item-descriptor of a repository. You can do it directly in the Repository using RQLs or do it programatically if required.
Now that we know how to associate inventory to a SKU, we can move ahead and learn the process of associating price with a SKU.




  1. It looks like elseif condition shown may not be true regarding stockLevel for inStock and outOfStock.Thanks for the creating such a nice document.

    1. Thanks for pointing out the typo :)
      This has been corrected now.



Get All The Latest Updates Delivered Straight Into Your Inbox For Free!