Hi
We reach some problem in our production app. Some users rise the problem that they are not seeing all products, i was debugging the code from where we are taking them :
[HttpPost]
[Route("search")]
public async Task<SearchProductsResponse> SearchProducts(SearchProductsRequest request)
{
User user = Dynamicweb.Security.UserManagement.User.GetUserByID(request.UserId);
var mappingOptions = await PrepareMappingOptions(user, HttpContext.Current.GetUserLocationDictionaryFromCookie());
using (var client = new HttpClient())
{
var queryParams = new List<string>
{
"RepositoryName=Products",
"QueryName=ProductsList",
"ProductSettings.FilledProperties=Id,Name,Number,Price,Discount,Manufacturer,ProductFields,StockUnits",
$"PageSize={request.PageSize}",
$"CurrentPage={request.PageNo}",
$"LanguageId={request.LanguageId}"
};
var sessionLocation = user.GetSessionLocation();
if (!string.IsNullOrWhiteSpace(sessionLocation))
queryParams.Add($"SessionLocation={sessionLocation}");
var priceGroup = user.GetCustomerPriceGroup();
if (!string.IsNullOrWhiteSpace(priceGroup))
queryParams.Add($"PriceGroup={priceGroup}");
if (!string.IsNullOrWhiteSpace(request.UserId.ToString()))
queryParams.Add($"UserID={request.UserId}");
if (!string.IsNullOrWhiteSpace(request.GroupId))
queryParams.Add($"GroupID={request.GroupId}");
if (!string.IsNullOrWhiteSpace(request.SearchString))
queryParams.Add($"Search={request.SearchString}");
if (!string.IsNullOrWhiteSpace(request.Facets))
queryParams.Add(request.Facets);
var url = $"https://{Request.RequestUri.Authority}/dwapi/ecommerce/products/search?{string.Join("&", queryParams)}";
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {request.token}");
var response = await client.GetAsync(url);
if (response.StatusCode != System.Net.HttpStatusCode.OK)
{
LogManager.System.GetLogger(LogCategory.Monitoring, "PLP").Info(response.Content.ReadAsStringAsync().Result);
return new SearchProductsResponse
{
CurrentPage = 1,
FacetGroups = new List<FacetGroup>(),
PageCount = 1,
PageSize = 1,
Products = new List<ProductDetails>(),
TotalProductsCount = 0
};
}
var dwResult = await response.Content.ReadAsAsync<DW_SearchProductsResponse>();
return new SearchProductsResponse
{
CurrentPage = dwResult.CurrentPage,
FacetGroups = dwResult.FacetGroups,
PageCount = dwResult.PageCount,
PageSize = dwResult.PageSize,
TotalProductsCount = dwResult.TotalProductsCount,
Products = dwResult.Products.ToProductDetails(mappingOptions)
};
}
}
and it seems somehow it is caused by Live Integration or maybe the response from LI becaues when i remove line of code with token :
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {request.token}");
The missing products appeared again .
To be more wierd because this is old app and search still based on RApido component and is setup in common way the products that are missing from endpoint call are available in this search
Do you know maybe what might be the reason
Are we missing something in api call ?
PS
I have suspiciouss that is connect with stoc that could have negative value,beacause this is most common case but i also notice product that has possitive stock value and is still missing on response from dwapi
Regards
Mateusz