London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!
London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!
Using Product associations (or relations), there are a number of ways you can promote products:
Merchandising items can be displayed on category, product, shopping cart, checkout, or receipt pages.
In the following we will provide some examples of how to implement product associations.
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
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;
}
}
}
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
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();
}
Last updated: Oct 21, 2014