Friday, October 22, 2010

Create an Operation Sequence Component in Commerce Server 2009

  1. Create a class that inherits OperationSequenceComponent class.
  2. Add the following library in the includes
    • Microsoft.Commerce.Providers.Components;
    • Microsoft.CommerceServer.Runtime.Orders;
    • Microsoft.Commerce.Contracts.Messages;
    • Microsoft.Commerce.Broker;
    • Microsoft.Commerce.Common.MessageBuilders;
    • Microsoft.Commerce.Contracts;
  3. Override one of the following methods inside OperationSequenceComponents
    • ExecuteQuery – Should be override if you intend to Query an Entity.
    • ExecuteCreate – Should be override if you intend to Add a new entry to the Entity.
    • ExecuteUpdate – Should be override if you intend to Update an existing Entity.
    • ExecuteDelete – Should be override if you intend to Delete an existing Entity.
    Each methods has a parameter of CommerceUpdateOperation, OperationCacheDictionary, and CommerceUpdateOperationResponse. Each parameter is self explanatory but I will try to explain.
    CommerceUpdateOperation holds the information of the entity that you want to create, read, update or delete (CRUD). These are the Model information or the searched entity.
    OperationCacheDictionary hold the current information of the Entity you want to create, read, update or delete (CRUD). These information are saved to cache and the data is serialized, and these data will be used in the other OperationSequenceComponent. Either read, or updated.
    CommerceUpdateOperationResponse holds the information you want to return to the calling Method. In Commerce Foundation, you can specify what related model of the Entity you want to return.
  4. If you have completed your class. Add it in the OperationSequence of the right MessageHandler in ChannelConfiguration.config where you want to add your Component. Say if you want to add a Component when you update and Entity for example Basket, the right MessageHandler should be CommerceUpdateOperation_Basket. Each component added in the Operation Sequence is hierarchal . The component that you add should be in a signed library.

No comments:

Post a Comment