private static ProductSearchServiceResponse SearchProductsLocal(ProductSearchServiceRequest request)
            {
                var queryCriteria = request.QueryCriteria;

                if (queryCriteria.Context == null || queryCriteria.Context.ChannelId.HasValue == false)
                {
                    throw new DataValidationException(DataValidationErrors.Microsoft_Dynamics_Commerce_Runtime_RequiredValueNotFound, "The channel identifier on the query criteria context must be specified.");
                }

                GetProductServiceRequest getProductsServiceRequest = new GetProductServiceRequest(
                    queryCriteria,
                    request.RequestContext.GetChannelConfiguration().DefaultLanguageId,
                    false /*FetchProductsAvailableInFuture*/,
                    request.QueryResultSettings,
                    queryCriteria.IsOnline);

                ProductSearchResultContainer result = request.RequestContext.Runtime.Execute <ProductSearchServiceResponse>(
                    getProductsServiceRequest,
                    request.RequestContext).ProductSearchResult;

                // populate the active variant product id if this was a search by item or barcode
                if ((!queryCriteria.ItemIds.IsNullOrEmpty() || !queryCriteria.Barcodes.IsNullOrEmpty()) && !queryCriteria.SkipVariantExpansion)
                {
                    SetActiveVariants(queryCriteria, result);
                }

                if (!queryCriteria.Refinement.IsNullOrEmpty())
                {
                    result.Results = ProductRefinement.RefineProducts(result.Results, queryCriteria.Refinement);
                }

                return(new ProductSearchServiceResponse(result));
            }
            /// <summary>
            /// Get products based on the <paramref name="serviceRequest"/>.
            /// </summary>
            /// <param name="serviceRequest">The product retrieval request.</param>
            /// <returns>The product retrieval response.</returns>
            private static ProductSearchServiceResponse GetProducts(GetProductServiceRequest serviceRequest)
            {
                GetProductsHelper getProductsHandler = new GetProductsHelper(serviceRequest);

                return(new ProductSearchServiceResponse(getProductsHandler.GetProducts()));
            }
 /// <summary>
 /// Initializes a new instance of the <see cref="GetProductsHelper"/> class.
 /// </summary>
 /// <param name="request">The request for getting products.</param>
 public GetProductsHelper(GetProductServiceRequest request)
 {
     this.request = request;
     this.DataStoreManagerInstance = DataStoreManager.InstantiateDataStoreManager(request.RequestContext);
     this.DataStoreManagerInstance.RegisterDataStoreAccessor(DataStoreType.L2Cache, ProductL2CacheDataStoreAccessor.Instantiate, request.RequestContext);
 }