Try our conversational search powered by Generative AI!

Loading...
ARCHIVED This content is retired and no longer maintained. See the latest version here.

Recommended reading 

Using Product associations (or relations), there are a number of ways you can promote products:

  • Up-selling: presents newer or better versions of the same product for the customer's consideration. For example, when displaying a television, display newer models in the same product line.
  • Cross-selling: shows related products to the customer. For example, when displaying a shirt, cross selling can display other shirts by the same designer.
  • Accessories: encourages the customer to add related or required accessories to their 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.

Merchandising items can be displayed on category, product, shopping cart, checkout, or receipt pages.

Implementation examples

In the following we will provide some examples of how to implement product associations.

Product recommendations

You can give site visitors product recommendations based on the purchasing history of other customers. Shoppers can also view items that other customers have 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();
            }
Do you find this information helpful? Please log in to provide feedback.

Last updated: Oct 21, 2014

Recommended reading