---
title: Multi-market examples
slug: commerce-connect-14/docs/multi-market-examples
docTags: 
createdAt: 2026-07-23T10:25:32.641Z
---

## Change market to display

![](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/PlN7oNwWf87tAOFsHIaoW_7e51644-choosemartket.png)

**Example:** Get all available markets.

```csharp
public IEnumerable GetAvailableMarkets()
      {
        var marketService = ServiceLocator.Current.GetInstance<IMarketService>();
        // Get all available markets.
        return marketService.GetAllMarkets();
      }
```

**Example:** Get current markets.

```csharp
public IMarket GetCurrentMarket()
      {
        var currentMarketService = ServiceLocator.Current.GetInstance<ICurrentMarket>();
        // Get current markets.
        return currentMarketService.GetCurrentMarket();
      }
```

**Example:** Set current markets.

```csharp
public void SetCurrentMarket(MarketId marketId)
      {
        var currentMarketService = ServiceLocator.Current.GetInstance<ICurrentMarket>();
        // Get current markets.
        currentMarketService.SetCurrentMarket(marketId);
      }
```

## Display entry listing, prices, and discounts per market

Examples of displaying the entries listed with pricing and discounts for a selected market.

![](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/8LW1pCMdm6qqAAyua_8e6_9e3fe3c-changemartket.png)

![](https://api.archbee.com/api/optimize/BrbvVORKJ5iIeSMZye5kI/Zku6Fs7khnS1p4cl_pvmF_8d1fb93-changecurrency.png)

**Example:** Get the price for an entry per market.

**Commerce Connect Version 12.8 and higher**.

```csharp
public Price GetSalePrice(Entry entry, decimal quantity)
      {
        var currentMarketService = ServiceLocator.Current.GetInstance<ICurrentMarket>();
        var currentMarket = currentMarketService.GetCurrentMarket();
        var currency = currentMarket.DefaultCurrency;
        List<CustomerPricing> customerPricing = new List<CustomerPricing>();
        customerPricing.Add(CustomerPricing.AllCustomers);
    
        var principal = PrincipalInfo.CurrentPrincipal;
        if (principal != null)
          {
            if (!string.IsNullOrEmpty(principal.Identity.Name))
              {
                customerPricing.Add(new CustomerPricing(CustomerPricing.PriceType.UserName, principal.Identity.Name));
              }
    
            CustomerContact currentUserContact = principal.GetCustomerContact();
            if (currentUserContact != null && !string.IsNullOrEmpty(currentUserContact.EffectiveCustomerGroup))
              {
                customerPricing.Add(new CustomerPricing(CustomerPricing.PriceType.PriceGroup, currentUserContact.EffectiveCustomerGroup));
              }
          }
    
        IPriceService priceService = ServiceLocator.Current.GetInstance<IPriceService>();
        PriceFilter filter = new PriceFilter()
          {
            Quantity = quantity,
            Currencies = new Currency[] { currency },
            CustomerPricing = customerPricing
          };
    
        // return less price value
        IPriceValue priceValue = priceService.GetPrices(currentMarket.MarketId, DateTime.UtcNow, new CatalogKey(entry.ID), filter)
            .OrderBy(pv => pv.UnitPrice)
            .FirstOrDefault();
    
        if (priceValue != null)
          {
            return new Mediachase.Commerce.Catalog.Objects.Price(priceValue.UnitPrice);
          }
    
        return null;
      }
```

**Commerce Connect Versions 10-12.7**

```csharp
public Price GetSalePrice(Entry entry, decimal quantity)
      {
        var currentMarketService = ServiceLocator.Current.GetInstance<ICurrentMarket>();
        var currentMarket = currentMarketService.GetCurrentMarket();
        var currency = currentMarket.DefaultCurrency;
        List<CustomerPricing> customerPricing = new List<CustomerPricing>();
        customerPricing.Add(CustomerPricing.AllCustomers);
    
        var principal = PrincipalInfo.CurrentPrincipal;
        if (principal != null)
          {
            if (!string.IsNullOrEmpty(principal.Identity.Name))
              {
                customerPricing.Add(new CustomerPricing(CustomerPricing.PriceType.UserName, principal.Identity.Name));
              }
    
            CustomerContact currentUserContact = principal.GetCustomerContact();
            if (currentUserContact != null && !string.IsNullOrEmpty(currentUserContact.EffectiveCustomerGroup))
              {
                customerPricing.Add(new CustomerPricing(CustomerPricing.PriceType.PriceGroup, currentUserContact.EffectiveCustomerGroup));
              }
          }
    
        IPriceService priceService = ServiceLocator.Current.GetInstance<IPriceService>();
        PriceFilter filter = new PriceFilter()
          {
            Quantity = quantity,
            Currencies = new Currency[] { currency },
            CustomerPricing = customerPricing
          };
    
        // return less price value
        IPriceValue priceValue = priceService.GetPrices(currentMarket.MarketId, FrameworkContext.Current.CurrentDateTime, new CatalogKey(entry.ID), filter)
            .OrderBy(pv => pv.UnitPrice)
            .FirstOrDefault();
    
        if (priceValue != null)
          {
           return new Mediachase.Commerce.Catalog.Objects.Price(priceValue.UnitPrice);
          }
    
        return null;
      }
```

**Example:** Get discounts per market.

```csharp
public Price GetDiscountPrice(ContentReference contentLink, Curreny currency)
      {
        var currentMarketService = ServiceLocator.Current.GetInstance<ICurrentMarket>();
        var promotionEngine = ServiceLocator.Current.GetInstance<IPromotionEngine>();
        var market = currentMarketService.GetCurrentMarket();
        return promotionEngine.GetDiscountPrices(contentLink, market, currency).First().DiscountPrices.OrderBy(p=>p.Price).First().Price;
      }
```
