protected virtual async Task <IEnumerable <ProductIdentifier> > GetSameCategoryProductIdentifier(GetProductIdentifiersParam getProductIdentifiersParam, string categoryId) { if (getProductIdentifiersParam == null) { throw new ArgumentNullException(nameof(getProductIdentifiersParam)); } if (string.IsNullOrWhiteSpace(categoryId)) { throw new ArgumentException(GetMessageOfNullWhiteSpace(), nameof(categoryId)); } var sameCategoryProductIdentifier = new List <ProductIdentifier>(); var productInSameCategoryParam = new GetProductsInSameCategoryParam() { CategoryId = categoryId, CultureInfo = getProductIdentifiersParam.CultureInfo, Scope = getProductIdentifiersParam.Scope, MaxItems = getProductIdentifiersParam.MaxItems, SortBy = "score", InventoryLocationIds = await InventoryLocationProvider.GetInventoryLocationIdsForSearchAsync(), CurrentProductId = getProductIdentifiersParam.ProductId, AvailabilityDate = FulfillmentContext.AvailabilityAndPriceDate }; var sameCategoryProducts = await RelationshipRepository.GetProductInSameCategoryAsync(productInSameCategoryParam).ConfigureAwait(false); if (sameCategoryProducts.Documents.Any()) { sameCategoryProductIdentifier = sameCategoryProducts.Documents.Select(d => { string variantId = null; if (d.PropertyBag.ContainsKey(VariantPropertyBagKey)) { variantId = d.PropertyBag[VariantPropertyBagKey] as string; } return(new ProductIdentifier { ProductId = d.ProductId, VariantId = variantId }); }).ToList(); } return(sameCategoryProductIdentifier); }
protected virtual async Task <IEnumerable <ProductIdentifier> > GetSameCategoryProductIdentifier(GetProductIdentifiersParam getProductIdentifiersParam, string categoryId) { Guard.NotNull(getProductIdentifiersParam, nameof(getProductIdentifiersParam)); Guard.NotNullOrWhiteSpace(categoryId, nameof(categoryId)); var sameCategoryProductIdentifier = new List <ProductIdentifier>(); var productInSameCategoryParam = new GetProductsInSameCategoryParam() { CategoryId = categoryId, CultureInfo = getProductIdentifiersParam.CultureInfo, Scope = getProductIdentifiersParam.Scope, MaxItems = getProductIdentifiersParam.MaxItems, SortBy = "score", InventoryLocationIds = await InventoryLocationProvider.GetInventoryLocationIdsForSearchAsync(), CurrentProductId = getProductIdentifiersParam.ProductId }; var sameCategoryProducts = await RelationshipRepository.GetProductInSameCategoryAsync(productInSameCategoryParam).ConfigureAwait(false); if (sameCategoryProducts.Documents.Any()) { sameCategoryProductIdentifier = sameCategoryProducts.Documents.Select(d => { string variantId = null; if (d.PropertyBag.ContainsKey(VariantPropertyBagKey)) { variantId = d.PropertyBag[VariantPropertyBagKey] as string; } return(new ProductIdentifier { ProductId = d.ProductId, VariantId = variantId }); }).ToList(); } return(sameCategoryProductIdentifier); }