Hide menu Last updated: Oct 12 2015

Product associations (or relations) can promote products in the following ways:

  • Up-selling. Presents newer or better versions of the product. For example, when displaying a television, display newer models in the same product line.
  • Cross-selling. Shows related products. For example, when displaying a shirt, cross selling displays other shirts by the same designer.
  • Accessories. Encourage the customer to add related or required accessories to the shopping cart when purchasing an item. Examples include spare batteries, memory cards, or cables for electronics.
  • Warranties. Allow dependent items, such as product warranties, to be sold with a product.

You can display merchandising items on category, product, shopping cart, checkout, or receipt pages.

Implementation examples

The following examples show how to implement product associations.

Product recommendations

You can provide product recommendations based on the purchasing history of other customers. Shoppers also can view items that other customers bought in a personalized storefront. Recommendations are dynamically displayed based on defined business logic.

Example: utilizing an entry association to expose a predefined set of product recommendations for an entry

C#
private void SampleGetRecomendedEntries(Entry entry)
            {
              Association[] assocs = entry.Associations;
              string key = "CrossSell"; // You can define association keys in Commerce Manager.
              bool matchFound = false;

              if (assocs == null) return;

              foreach (Association assoc in assocs)
              {
                if (assoc.EntryAssociations == null) continue;

                // Match the association string key defined in the Commerce Manager or elsewhere.
                if (assoc.Name == key && assoc.EntryAssociations.Association.Length > 0)
                {
                  matchFound = true;

                  // The Association property exposes a EntryAssociation[] array.
                  // The EntryAssociation object has a property Entry, which gives you access to each Entry.
                  YourRepeaterControl.DataSource = assoc.EntryAssociations.Association;
                  YourRepeaterControl.DataBind();

                  // Break from foreach loop.
                  break;
                }
              }
            }

Recently viewed products

You can remind customers of recent products of interest by displaying a list of the last products viewed in the store. This is traditionally used in the shopping cart and product pages for easier navigation.

Example: binding a collection of recently viewed entry objects

C#
private void SampleGetRecentlyViewedEntryCollection()
            {
              NameValueCollection history = StoreHelper.GetBrowseHistory();

              List<Entry> recentlyViewedEntries = new List<Entry>();
              string[] keys = history.GetValues("Entries");

              if (keys != null)
              {
                bool isFirst = true;
                foreach (string key in keys)
                {
                  // Skip the first item.
                  if (isFirst)
                  {
                    isFirst = false;
                    continue;
                  }

                  if (!String.IsNullOrEmpty(key))
                  {
                    Entry entry = CatalogContext.Current.GetCatalogEntry(key);
                    if (entry != null)
                      recentlyViewedEntries.Add(entry);
                  }
                }
              }

              if (recentlyViewedEntries.Count == 0)
              {
                // No recently viewed entries were found.
                return;
              }

              // Bind the collection to your control.
              YourRepeaterControl.DataSource = recentlyViewedEntries.ToArray();
              YourRepeaterControl.DataBind();
            }

Comments