Thursday, January 16, 2014

Creating a Standard Commerce Item : ATG

Follow these steps to create a new CommerceItem and associate it with an Order:

1. Call CommerceItemManager.createCommerceItem().

2. Make any changes to the CommerceItem, such as setting the quantity.

3. Call CommerceItemManager.addItemToOrder(pOrder, pCommerceItem) to add the CommerceItem to       the Order.

Refer to the below example:


// Get a reference to the OrderManager
OrderManager orderManager = (OrderManager)
  request.resolveName("/atg/commerce/order/OrderManager");

// Create the CommerceItem
CommerceItem commerceItem =
  commerceItemManager.createCommerceItem(pCatalogRefId);
commerceItem.setQuantity(3);

// Add the CommerceItem to the Order
commereceItemManager.addItemToOrder(pOrder, commerceItem);


Note: createCommerceItem() will work even if you pass it a nonexistent catalog reference ID. This allows you to use ATG Commerce as an ordering system with multiple catalogs, some of which may not have repositories. If you want to prevent this behavior, you must institute a check.

Auxiliary data is a construct that exists in a CommerceItem object. This structure allows arbitrary data to be stored with a CommerceItem.

This data could be the options for a CommerceItem such as size and color. It could also refer to the product reference in the catalog. An important concept is that any data that is inserted into the auxiliary data can be serialized at any time in a system that contains remote components.

When defining AuxiliaryData objects, the classes must be defined as serializable. As initially defined, the class includes ProductID, ProductRef, PropertyValue, and CatalogRef properties.



No comments:

Popular Posts