Hide menu Last updated: Oct 12 2015

This topic describes how to specify items and quantities for a product package. When you configure items for a package, you get the child relations from the parent package item Entry object. The quantities (among other information) are retrieved from the CatalogEntryRelation data table.

Classes in this topic are in the Mediachase.Commerce.Catalog.Dto namespace.

How it works

The entryInstance.Entries.Entry contains the package item child entries, but does not contain the relation information.

The CatalogRelationDto is a DataSet with the following DataTables:

  • CatalogEntryRelation
  • CatalogItemAsset
  • CatalogNodeRelation
  • NodeEntryRelation

The CatalogEntryRelation is a DataTable with the following columns:

  • ParentEntryId
  • ChildEntryId
  • RelationTypeId
  • Quantity
  • GroupName
  • SortOrder

The Quantity field contains the quantities for the package's child entries. The CatalogContext.Current.GetCatalogRelationDto() method, called with the proper parameters, passes execution down the chain from CatalogRelationManager to CatalogRelationAdmin, where ultimately the stored procedure [ecf_CatalogRelation] is run. In that stored procedure, certain select queries are conditionally executed depending on parameters, and results are mapped in-memory to some of the DataTable objects above.

Example: A method GetPackageChildEntries() creating a List of KeyValuePair objects and adding pairs of child entry IDs and quantities from the CatalogEntryRelation DataTable.

public List<KeyValuePair<int, decimal>> GetPackageChildEntries(Entry parent)
  List<KeyValuePair<int, decimal>> childEntryQuanities = new List<KeyValuePair<int, decimal>>();

  CatalogRelationResponseGroup group = 
    new CatalogRelationResponseGroup(CatalogRelationResponseGroup.ResponseGroup.CatalogEntry);
  CatalogRelationDto relations = CatalogContext.Current.GetCatalogRelationDto(0, 0, parent.CatalogEntryId, string.Empty, group);

  if (relations != null && relations.CatalogEntryRelation != null && relations.CatalogEntryRelation.Count > 0)
    foreach (CatalogRelationDto.CatalogEntryRelationRow row in relations.CatalogEntryRelation.Rows)
      childEntryQuanities.Add(new KeyValuePair<int, decimal>(row.ChildEntryId, row.Quantity));

  return childEntryQuanities;

The GetCatalogRelationDto() signature is as follows, with a description on how each parameter is used in the sample above:

public CatalogRelationDto GetCatalogRelationDto(int catalogId, int catalogNodeId, int catalogEntryId, string groupName, CatalogRelationResponseGroup responseGroup)
  • catalogId. Passing 0 here, do not filter by catalog.
  • catalogNodeId. Passing 0 here, do not filter by catalog.
  • catalogEntryId. The catalog entry ID of the package.
  • groupName. Passing empty string here, do not filter by group name. You can query the GroupName values of the CatalogEntryRelation to specify this as an additional filtering query.
  • responseGroup. Passing the CatalogRelationResponseGroup.ResponseGroup.CatalogEntry enum value to specify that the corresponding select query in the ecf_CatalogRelation stored procedure be executed, and its results be mapped to the CatalogEntryRelation data table.  The enum has the Flags attribute.
    ResponseGroup.CatalogNode maps execution results to CatalogNodeRelation, and ResponseGroup.NodeEntry maps execution results to NodeEntryRelation.

Related topic