Skip to content

Commit e2d6508

Browse files
authored
Merge pull request #52 from dynamicweb/dbe/24852-Fix-duplicate-requests-for-non-existing-products
Fix duplicate requests for non existing products
2 parents 2d8a428 + 58f5094 commit e2d6508

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Cache/ResponseCache.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ public static bool IsProductInCache(ResponseCacheLevel productCacheLevel, string
205205

206206
if (cachedProductInfo.TryGetValue(productIdentifier, out var productInfo))
207207
{
208+
if (productInfo is null) return true;
208209
return Equals(currency.Code, productInfo["CurrencyCode"]);
209210
}
210211
}

src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Dynamicweb.Ecommerce.DynamicwebLiveIntegration.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<Version>10.4.26</Version>
3+
<Version>10.4.27</Version>
44
<AssemblyVersion>1.0.0.0</AssemblyVersion>
55
<Title>Live Integration</Title>
66
<Description>Live Integration</Description>

src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Products/ProductManager.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ private static bool FetchProductInfosInternal(List<PriceProductSelection> produc
212212
// Parse the response
213213
Dictionary<string, ProductInfo> prices = ProcessResponse(settings, response, logger, context);
214214

215-
if (prices != null && prices.Count > 0)
215+
if (prices != null)
216216
{
217217
if (updateCache)
218218
{
@@ -225,7 +225,14 @@ private static bool FetchProductInfosInternal(List<PriceProductSelection> produc
225225
cachedProductInfos.Remove(productKey);
226226
cachedProductInfos.Add(productKey, prices[productKey]);
227227
}
228-
}
228+
// Cache empty values for products that were in the request but were not returned in the response
229+
230+
foreach (var priceProductSelection in productsForRequest)
231+
{
232+
var productIdentifier = ProductProvider.GetProductIdentifier(settings, priceProductSelection.Product, priceProductSelection.UnitId);
233+
cachedProductInfos.TryAdd(productIdentifier, null);
234+
}
235+
}
229236
}
230237
}
231238
else

0 commit comments

Comments
 (0)