When an application has added new properties to the core Commerce objects, it may be necessary to modify the cloning process. Usually, all repository items referenced by the cloned item are also cloned into new transient repository items. This is known as the deep clone. However, you may want a shallow cloning of new properties or you may want to eliminate certain properties entirely from the cloning process.
Adding Objects for Cloning
You may extend core Commerce objects, for example: Order
, ShippingGroup
, PaymentGroup
, Relationship
. For example, you may have extended the default OrderImpl
object type by creating a MyOrderImpl
to add new properties. The configuration of the clone editing components may require adjustments or you may have to create class extensions.
If you have extended the core Commerce objects, the new object type and its new properties must be identified to the clone editing feature so that the new properties are copied to their original order counterpart during the reconciliation process. You must map which properties should be copied based on the type of object. The following is an example of the configuration for the atg.commerce.order.OrderImpl
object type.
/atg/commerce/custsvc/order/edit/OrderPropertyHandler.properties$ $class=atg.commerce.order.edit.OrderPropertyEditHandler cloneEditManager=/atg/commerce/custsvc/order/edit/CloneEditManager keyPropertyName=id # map of payment group properties that are copied from the clone to the original # during reconcilation. The class name is the key propertiesToCopyOnUpdate=\ atg.commerce.order.OrderImpl=description,,state,,stateDetail,,taxPriceInfo ,,priceInfo,,specialInstructions
To add a new object type named MyOrderImpl
, you would create an /atg/commerce/custsvc/
file in your customization directory and add the new object type and its properties, which will be appended to the default
order/edit/OrderPropertyHandler.propertiesOrderPropertyHandler
file:
propertiesToCopyOnUpdate=\ myapp.commerce.order.MyOrderImpl=language,,locale
Note: Only new properties of the class need to be defined as all inherited properties are already covered by the super-type configurations. Additionally, it is not necessary to specify any new properties that will not be updated during the modification process.
The same type of configuration change is needed for extensions to the CommerceItem
, ShippingGroup
, PaymentGroup
and Relationship
objects. See CommerceItemHandler
, ShippingGroupHandler
, PaymentGroupHandler
and RelationshipHandler
respectively.
There are two ways that the repository cloning process can be managed: By excluding properties entirely from the cloning process, or by specifying which properties should use deep versus shallow cloning.
Excluding Properties from Cloning
The cloning feature can be configured to exclude certain properties from the clone process in the atg/commerce/custsvc/order/edit/processor/CloneOrderForEdit
component. The excludedOrderProperties
property maps order repository item types to a list of properties that should be excluded from the cloning process. The following is the default configuration that excludes the pricelist
and pricingModel
properties from the cloning process:
excludedOrderProperties= itemPriceInfo=priceList, pricingAdjustment=pricingModel
In this example, all properties that reference an item type of itemPriceInfo
or pricingAdjustment
will be cloned, but the pricelist
and pricingModel
properties will not be cloned and will be left null.
To exclude multiple properties:
excludedOrderProperties= itemPriceInfo=priceList|discounted|currencyCode
Specifying Deep Versus Shallow Clone
To specify the level of clone, extend the CloneOrderForEdit
processor’s createCloningPropExceptionsMap
API to create a hierarchical map that specifies which properties have special handling called property exceptions.
The keys used in this map are property names while values are null or another map if the property is an item.
The following example performs a shallow clone on any property named priceinfo
:
Map priceInfoExc = new HashMap(); priceInfoExc.put("priceInfo",null); return priceInfoExc;
The following example performs a shallow clone of only the property named pricelist
on any item found in a property named priceInfo
:
Map priceInfoExc = new HashMap(); Map priceInfoProps = new HashMap(); priceInfoProps.put("pricelist",null); priceInfoExc.put("priceInfo", priceInfoProps); return priceInfoExc;
An application can also introduce a custom CloneEditHandler
to perform special handling on any application-specific properties. For example, an application may want to exclude a custom property from the repository and handle the cloning process another way. The CloneEditHandler
callback interface is executed after the repository cloning process is finished and provides an opportunity for applications to execute post-cloning logic.
Gift with Purchase Promotion Orders
Gift with Purchase is a Commerce feature that extends the CommerceItem
object to store Gift with Purchase meta data within repository markers.
Commerce Service Center’s clone editing feature supports the cloning and reconciliation of the Gift with Purchase Commerce item markers when an order containing gifts is modified by an agent.
The SubPropertyHandler
interface defines the requirements for implementing a CloneEditHandler
for objects referenced by a sub-property of another parent object. The parent object is the CommerceItem
and the markers are the objects referenced by the sub-property gwpMarkers
.
The subclass CollectionSubPropertyEditHandler
extends the CollectionEditHandler
class and implements a SubPropertyHandler
for handling collection sub-properties.
The CommerceItemMarkerEditHandler
class extends the CollectionSubPropertyHandler
class to handle a collection property that contains Commerce item markers. A component of this type, which is named /atg/commerce/custsvc/order/edit/CommerceItemGWPMarkerHandler
, is defined by Commerce Service Center to handle clone and reconciliation of Gift with Purchase Commerce item markers.
The following is an example of the CommerceItemGWPMarkerHandler
:
$class=atg.commerce.order.edit.CommerceItemMarkerEditHandler keyPropertyName=repositoryId sortPropertyName=creationDate collectionPropertyName=gwpMarkers cloneEditManager=/atg/commerce/custsvc/order/edit/CloneEditManager propertiesToCopyOnUpdate=\ gwpCommerceItemMarker=key,,value,,data,,targetedQuantity,, automaticQuantity,,selectedQuantity
The CollectionEditHandler
implementation supports the integration of multiple SubPropertyHandler
components. These components are configured on the CollectionEditHandler
through the subPropertyHandlers
property.
The /atg/commerce/custsvc/order/edit/CommerceItemHandler
contains a CollectionEditHandler
that handles Commerce items and references the SubPropertyHandler
for GWP markers:
$class=atg.commerce.csr.order.edit.CSRCommerceItemEditHandler subPropertyHandlers=/atg/commerce/custsvc/order/edit/CommerceItemMarkerHandler,\ /atg/commerce/custsvc/order/edit/CommerceItemGWPMarkerHandler
Note that the CommerceItemHandler
references two subPropertyHandlers
; one for each marker property defined on a CommerceItem
.
Note: The Commerce Service Center Copy Order and Submit Now features exclude Commerce item markers when making a copy of the order. This means that no Gift with Purchase related information, such as which items are manually selected gifts, will be carried over to the new order.