The buying context is part of the Intershop Commerce Management, released in 7.10.33.1, but it is also used in the upcoming Organization Hierarchy Service (OHS) which is currently still in development.
As of 7.10.33 the Buying Context determines the checkout process in the Intershop Commerce Management (ICM) in addition to the settings for the Selling Organization (Channel) and buying user's customer assignment. The Buying Context was introduced in the context of the Organization Hierarchy Service (OHS). An organization hierarchy is a reflection of the customer's real organization structure. It is more detailed than ICM's previous customer representation having only one single entity.
Term | Description |
---|---|
Buying Context | A Buying Context is formed by a Buying Organization's hierarchy tree and a specific node, called Group, of this tree. |
Buying Organization | Actor that represents a self-contained business organization acting on the buy-side in Intershop Commerce Management. |
Group | Entity of the hierarchy tree |
ICM | Intershop Commerce Management |
OHS | Organization Hierarchy Service |
PWA | Progressive Web App |
The Organization Hierarchy Service (OHS) is the foundation for Buying Context creation. A Buying Context is formed by a Buying Organization's hierarchy tree and a specific node, called Group, of this tree.
Example: The Buying Organization BioTech
and its Group BioTech_Jena
form the Buying Context BioTech_Jena@BioTech
.
The following diagram illustrates the big picture of the Buying Context and the basic interactions between the involved systems.
The steps in the process are described as follows:
The user logs in to PWA for the respective Buying Organization (former Customer).
The OHS holds the hierarchy tree which a Buying Organization spans for its structural entities, like subsidiaries, departments, teams, etc. The nodes of the tree are called Groups. The PWA retrieves all Groups (entities of the hierarchy tree) the user is assigned to with a specific role, e.g. Buyer.
From the list provided by the OHS in the PWA, the user selects the Group for which to place an order.
When the user creates a new basket, the ID of the selected Group - and the ID of the Buying Organization (to identify the Group uniquely throughout all Buying Organization hierarchies) - are transmitted to ICM via a URL matrix parameter with the according REST request and every subsequent REST request to the /baskets
resource as well as its sub-resources.
ICM validates the values sent with the matrix parameter by a call to OHS to ensure that the Buying Organization and Group exist.
Note
The created basket is bound to the provided Buying Context and can only be manipulated and checked out in this context now.
The basket's Buying Context is stored at the created order in the course of the basket checkout. This way the original Buying Context remains, even if the structure of the Buying Organization's hierarchy tree in OHS changes over the time.
In the PWA the user requests placed orders for all or particular Buying Contexts. The filtering is done using the buyingContext
query parameter.
A user of a Buying Organization can select a specific Group of this organization and place orders in the context of this Group. PWA forwards the selected Group to ICM via a matrix parameter inserted in the URL of arbitrary REST requests. The matrix parameter has the following structure: bctx={group_ID}@{buying_organization_ID}
.
POST http://{host}:{port}/INTERSHOP/rest/WFS/inSPIRED-inTRONICS_Business-Site/rest;loc=en_US;cur=USD;bctx=BioTech_Jena@BioTech/baskets?include=all
The length of the Buying Organization ID as well as the Group ID are limited to avoid exceeding the maximum URL length. Furthermore, these limitations are the reason why the matrix parameter's value does only contain the Buying Organization ID and the Group ID instead of the whole hierarchy path from the Buying Context's Group to hierarchy's root Group.
The Buying Organization as well as Group ID of the Buying Context are case-sensitive.
The Buying Context in ICM is represented by the following type:
public interface BuyingContext { GroupPath getGroupPath(); Group getRootGroup(); Group getGroup(); boolean isValidated(); Optional<OrganizationServiceResult<GroupPath>> getServiceResult(); }
The BuyingContext::getGroupPath() : GroupPath
method returns the GroupPath
type representing the whole path starting from Buying Context's Group upwards to Buying Organization hierarchy's root Group.
The BuyingContext::getRootGroup() : Group
method returns the root Group of Buying Organization's hierarchy.
The BuyingContext::getGroup() : Group
returns the Group representing the Buying Context.
The result of the BuyingContext::isValidated() : boolean
indicates whether the value provided by the Buying Context matrix parameter has already been validated by a call to the OHS. As this matrix parameter is provided by another system (e.g. PWA, arbitrary REST client) it might not be valid at all. Hence, ICM validates the provided value by calling OHS' REST interface to check if there is a representation for the Buying Organization and Group ID in the OHS.
The result of the BuyingContext::getServiceResult() : Optional<OrganizationServiceResult<GroupPath>>
indicates if the validation call to the OHS was successful or not. The returned OrganizationServiceResult<GroupPath>
contains a status code and possible errors.
The REST Servlet Filter com.intershop.component.organizationhierarchies.capi.filter.BuyingContextRestFilter
extracts the Buying Context from the bctx
matrix parameter and makes it available to the Application.
If a storefront REST request contains the Buying Context matrix parameter, the related Buying Context is available via com.intershop.component.organizationhierarchies.capi.buyingcontext.ApplicationBOBuyingContextExtension
. A shortcut to retrieve the current request's Buying Context is provided by com.intershop.component.organizationhierarchies.capi.buyingcontext.CurrentBuyingContextProvider
.
Baskets are Buying Context-aware in ICM now. This means, that a basket bound to a specific Buying Context is only retrievable and valid in this context.
The Buying Context is stored in the BASKET
table in the following columns:
BUYINGCONTEXTORGANIZATIONID
(VARCHAR256
) - Stores the ID of the Buying Organization in OHS.
BUYINGCONTEXTGROUPID
(VARCHAR256
) - Stores the ID of the Group in OHS.
The Buying Context which a basket is bound to is retrievable via com.intershop.component.basket.capi.extension.BasketBOBuyingContextExtension
on the Business Object layer.
The payload of the basket includes the Buying Context the basket is bound to.
{ "data": { ... "buyingContext": "BioTech_Jena@BioTech", ... } }
In the course of the order creation, the Buying Context which the ordered basket is bound to is stored at the order by the com.intershop.component.order_orm.internal.handlerchain.BuyingContextOrderCreationHandler
implementation. In contrast to the basket which only stores the values of the Buying Organization ID and Group ID, the whole Group path is stored at the order to keep this information at the order even if the structure of the Buying Organization's hierarchy tree in OHS changes over the time.
The complete Group path of the Buying Context is stored in the ISORDERBUYINGCONTEXT
table.
The Buying Context of an order is retrievable via com.intershop.component.order.capi.extension.OrderBOBuyingContextExtension
on the Business Object layer. The OrderBOBuyingContextExtension::createBuyingContext(BasketBO basketBO) : BuyingContext
method creates the Buying Context for the order from the specified basket.
The payload of the order includes the Buying Context which the order's basket was bound to. Additionally, the whole Group path - starting from the root Group downwards to Buying Context's Group - is returned as include if the value buyingContext
is specified for the include
query parameter.
{ "data": { ... "buyingContext": "BioTech_Jena@BioTech", ... }, "included": { "buyingContext": { "BioTech_Jena@BioTech": { "groupId": "BioTech_Jena", "groupName": "Bio Tech Location Jena", "groupPath": [ { "groupId": "BioTech_Root", "groupName": "Bio Tech Root" }, { "groupId": "BioTech_EMEA", "groupName": "Bio Tech EMEA" }, { "groupId": "BioTech_Germany", "groupName": "Bio Tech Germany" }, { "groupId": "BioTech_Jena", "groupName": "Bio Tech Location Jena" } ], "organizationId": "BioTech" } }, ... } }
In case of order list REST requests it is possible to filter orders by their Buying Context. The filtering is done using the filter[buyingContext]
query parameter.
The matrix parameter bctx
cannot be used for order filtering at all. The reason is that a user may request historical orders created for a Buying Context which does not exist any longer due to changes in the Buying Organization hierarchy.
Example: Buying Organization BioTech
decided to close the subsidiary BioTech_Erfurt
in the course of a company restructuring. However, a user might check some orders created in the Buying Context BioTech_Erfurt
after a certain period of time. If the orders were filtered by the value of the matrix parameter bctx
, the PWA would be forced to set a parameter value that is no longer valid because the Group BioTech_Erfurt
was deleted from the Buying Organization's hierarchy some time before. Furthermore, ICM would fail if it tried to validate a non-existing Buying Context at OHS.
This is the reason for orders being filtered by a query parameter and being ignored in the case of a GET
request to the /orders
resource.
The Buying Organization as well as Group ID of the Buying Context are case-sensitive.
Currently Buying Context is not supported for the following features:
Subscriptions (Recurring Orders)
Approval
When an unauthenticated user creates a new basket and logs in to ICM later, the line items of this basket are merged to a possibly existing basket that has been created in the context of the user account before. This is no problem as long as the user is assigned to exactly one customer. It needs to be decided which of the user's baskets the one of the unauthenticated user should be merged with if the registered user owns several active baskets bound to different Buying Context instances. The required adjustments have to be made in the PWA.
Currently there is no check whether a user is permitted to order for a specific Buying Context. This is going to be supported in the course of the introduction of a role concept in OHS and an authorization token functionality.