Adding a New Link to a Commerce Pipeline

To add new links to a commerce pipeline you need to override the default definition for the appropriate commerce pipeline.  Commerce pipelines are defined in XML so you use ATG’s XML combining feature to accomplish this.

For example if you want to add a new link to the ProcessOrder chain in the /atg/commerce/commercepipeline.xml you would create the following commercepipeline.xml in your local config.

[xml]<pipelinemanager>
<pipelinechain name="processOrder" xml-combine="append">
<pipelinelink transaction="TX_MANDATORY" name="authorizePayment" xml-combine="replace">
<processor jndi="/atg/commerce/order/processor/AuthorizePayment" />
<transition returnvalue="1" link="updateInventory" />
</pipelinelink>
<pipelinelink name="updateInventory" transaction="TX_MANDATORY">
<processor jndi="/betweengo/commerce/inventory/processor/ProcUpdateInventory" />
<transition returnvalue="1" link="updateGiftRepository" />
</pipelinelink>
</pipelinemanager>[/xml]

In this example we added the new updateInventory link which is inserted between the authorizePayment and updateGiftRepository links.

Combining XML in ATG

250/365 - Bricks

(Photo: 250/365 – Bricks by Kenny Louie)

ATG uses XML files sometimes instead of Java properties files for configuration. Combining them is not as straight-forward as with Java properties files but more flexible.

The XML File Combination section in the Nucleus: Organizing JavaBean Components chapter of the ATG Programming guide gives a good explanation. You can combine XML files using one of these methods.

  • replace
  • remove
  • append
  • append-without-matching
  • prepend
  • prepend-without-matching

In most cases you will append which is what ATG does by default if the tag is not already there. If the tag is already there then ATG does a replace by default.

Note that when you do a replace you only need to specify the bare minimum. But what is the bare minimum can be tricky. Here is a case where we made a property hidden. Note that I had to specify the table type as “multi” otherwise ATG assumed it was “auxiliary” even though it’s defined as “multi” in the original XML file.
[xml]<table name="foo" type="multi">
  <property name="bar" hidden="true" />
</table>[/xml]
In another case I wanted to update the id-spaces for orders but I had to first remove before appending because replace did not work in this case. This is how I did it.
[xml]<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<id-spaces>
<id-space xml-combine="remove" name="order" seed="1" batch-size="10000" prefix="o"/>
<id-space name="order" seed="100" batch-size="1" prefix="m"/>
</id-spaces>[/xml]
To see the result of XML combining you can use the Dynamo Administration Server’s Component Browser to go to the component and then click on the property which specifies the XML file(s).

For example to find the result of combining idspaces.xml’s you would go to http://localhost:8080/dyn/admin/nucleus/atg/dynamo/service/IdGenerator/?propertyName=initialIdSpaces.

To find the result of combining productCatalogs.xml’s you would go to http://localhost:8080/dyn/admin/nucleus/atg/commerce/catalog/ProductCatalog/?propertyName=definitionFiles.

To find the result of combining commercepipeline.xml’s you would go to http://localhost:8080/dyn/admin/nucleus/atg/commerce/PipelineManager/?propertyName=definitionFile.