private static void GetInventoryList(Inventory_V01 inventory, string storeId) { if (inventory != null && inventory.Items != null) { var catalog = Providers.CatalogProvider.GetCatalog("CN"); if (catalog != null && catalog.Items != null && catalog.Items.Count > 0) { foreach (string sku in catalog.Items.Keys) { // Find inventory item with a matching SKU. if (!inventory.Items.ContainsKey(sku)) { continue; } var catalogItem = catalog.Items[sku] as CatalogItem_V01; var inventoryItem = inventory.Items[sku] as InventoryItem_V01; if (catalogItem != null && inventoryItem != null) { if (catalogItem.InventoryList == null) { catalogItem.InventoryList = new WarehouseInventoryList(); } //Bug 231703:SPLUNK LOGS: CNDO - object ref not set because no checking on warehouse object if (inventoryItem.Warehouses != null) { catalogItem.InventoryList[storeId] = inventoryItem.Warehouses[storeId]; } } } } } }
public static void LoadInventory(string storeID) { string cachekey = string.Format("{0}{1}", INVENTORY_CACHE_PREFIX, storeID); Inventory_V01 inventory = HttpRuntime.Cache[cachekey] as Inventory_V01; if (Settings.GetRequiredAppSetting("LogCatalogCN", "false").ToLower() == "true") { var enumerator = HttpRuntime.Cache.GetEnumerator(); while (enumerator.MoveNext()) { var key = (string)enumerator.Key; var value = enumerator.Value; if (value == null) { LogRequest(string.Format("Cache Key: {0} is null", key)); } } } if (inventory == null) { inventory = GetInventory(storeID); } GetInventoryList(inventory, storeID); if (Settings.GetRequiredAppSetting("LogCatalogCN", "false").ToLower() == "true") { LogRequest(string.Format("Store ID: {0}", storeID)); LogRequest(string.Format("Inventory loaded: {0}", (inventory != null).ToString())); } }