public ActionResult DisplayItemById(string itemId, string parentItemId = null, string name = "MiniItem", string associationType = null, bool forcedActive = false, ItemResponseGroups responseGroups = ItemResponseGroups.ItemSmall, ItemDisplayOptions displayOptions = ItemDisplayOptions.ItemSmall) { return(DisplayItemNoCache(itemId, parentItemId, name, associationType, forcedActive, responseGroups, displayOptions)); }
//Called from banner/ProductImageAndPrice to avoid nested caching /// <summary> /// Displays the item by identifier no cache. /// </summary> /// <param name="itemId">The item identifier.</param> /// <param name="parentItemId">The parent item identifier.</param> /// <param name="name">The name.</param> /// <param name="associationType">Type of the association.</param> /// <param name="forcedActive">if set to <c>true</c> [forced active].</param> /// <param name="responseGroups">The response groups.</param> /// <param name="displayOptions">The display options.</param> /// <param name="bycode"></param> /// <returns>ActionResult.</returns> public ActionResult DisplayItemNoCache(string itemId, string parentItemId = null, string name = "MiniItem", string associationType = null, bool forcedActive = false, ItemResponseGroups responseGroups = ItemResponseGroups.ItemSmall, ItemDisplayOptions displayOptions = ItemDisplayOptions.ItemSmall, bool bycode = false) { var itemModel = CatalogHelper.CreateCatalogModel(itemId, parentItemId, associationType, forcedActive, responseGroups, displayOptions, bycode); return(itemModel != null?PartialView(name, itemModel) : null); }
/// <summary> /// Creates the catalog model. /// </summary> /// <param name="itemId">The item identifier.</param> /// <param name="parentItemId">The parent item identifier.</param> /// <param name="associationType">Type of the association.</param> /// <param name="forcedActive">if set to <c>true</c> [forced active].</param> /// <param name="responseGroups">The response groups.</param> /// <param name="display">The display.</param> /// <param name="byItemCode">if set to <c>true</c> gets item by code.</param> /// <returns> /// CatalogItemWithPriceModel. /// </returns> public static CatalogItemWithPriceModel CreateCatalogModel(string itemId, string parentItemId = null, string associationType = null, bool forcedActive = false, ItemResponseGroups responseGroups = ItemResponseGroups.ItemLarge, ItemDisplayOptions display = ItemDisplayOptions.ItemLarge, bool byItemCode = false) { var dbItem = CatalogClient.GetItem(itemId, responseGroups, UserHelper.CustomerSession.CatalogId, bycode: byItemCode); if (dbItem != null) { if (dbItem.IsActive || forcedActive) { PriceModel priceModel = null; PropertySet propertySet = null; //ItemRelation[] variations = null; ItemAvailabilityModel itemAvaiability = null; if (display.HasFlag(ItemDisplayOptions.ItemPropertySets)) { propertySet = CatalogClient.GetPropertySet(dbItem.PropertySetId); //variations = CatalogClient.GetItemRelations(itemId); } var itemModel = CreateItemModel(dbItem, propertySet); if (display.HasFlag(ItemDisplayOptions.ItemAvailability)) { var fulfillmentCenter = UserHelper.StoreClient.GetCurrentStore().FulfillmentCenterId; var availability = CatalogClient.GetItemAvailability(dbItem.ItemId, fulfillmentCenter); itemAvaiability = new ItemAvailabilityModel(availability); } if (display.HasFlag(ItemDisplayOptions.ItemPrice)) { var lowestPrice = PriceListClient.GetLowestPrice(dbItem.ItemId, itemAvaiability != null ? itemAvaiability.MinQuantity : 1); var outlines = OutlineBuilder.BuildCategoryOutline(CatalogClient.CustomerSession.CatalogId, dbItem.ItemId); var tags = new Hashtable { { "Outline", outlines.ToString() } }; priceModel = MarketingHelper.GetItemPriceModel(dbItem, lowestPrice, tags); itemModel.CatalogOutlines = outlines; // get the category name if (outlines.Count > 0) { var outline = outlines[0]; if (outline.Categories.Count > 0) { var category = outline.Categories.OfType<Category>().Reverse().FirstOrDefault(); if (category != null) { itemModel.CategoryName = category.Name; } } } } itemModel.ParentItemId = parentItemId; return string.IsNullOrEmpty(associationType) ? new CatalogItemWithPriceModel(itemModel, priceModel, itemAvaiability) : new AssociatedCatalogItemWithPriceModel(itemModel, priceModel, itemAvaiability, associationType); } } return null; }
//Called from banner/ProductImageAndPrice to avoid nested caching /// <summary> /// Displays the item by identifier no cache. /// </summary> /// <param name="itemId">The item identifier.</param> /// <param name="parentItemId">The parent item identifier.</param> /// <param name="name">The name.</param> /// <param name="associationType">Type of the association.</param> /// <param name="forcedActive">if set to <c>true</c> [forced active].</param> /// <param name="responseGroups">The response groups.</param> /// <param name="displayOptions">The display options.</param> /// <returns>ActionResult.</returns> public ActionResult DisplayItemByIdNoCache(string itemId, string parentItemId = null, string name = "MiniItem", string associationType = null, bool forcedActive = false, ItemResponseGroups responseGroups = ItemResponseGroups.ItemSmall, ItemDisplayOptions displayOptions = ItemDisplayOptions.ItemSmall) { var itemModel = CatalogHelper.CreateCatalogModel(itemId, parentItemId, associationType, forcedActive, responseGroups, displayOptions); return itemModel != null ? PartialView(name, itemModel) : null; }
public ActionResult DisplayItemById(string itemId, string parentItemId = null, string name = "MiniItem", string associationType = null, bool forcedActive = false, ItemResponseGroups responseGroups = ItemResponseGroups.ItemSmall, ItemDisplayOptions displayOptions = ItemDisplayOptions.ItemSmall) { return DisplayItemByIdNoCache(itemId, parentItemId, name, associationType, forcedActive, responseGroups, displayOptions); }
/// <summary> /// Creates the catalog model. /// </summary> /// <param name="itemId">The item identifier.</param> /// <param name="parentItemId">The parent item identifier.</param> /// <param name="associationType">Type of the association.</param> /// <param name="forcedActive">if set to <c>true</c> [forced active].</param> /// <param name="responseGroups">The response groups.</param> /// <param name="display">The display.</param> /// <param name="byItemCode">if set to <c>true</c> gets item by code.</param> /// <returns> /// CatalogItemWithPriceModel. /// </returns> public static CatalogItemWithPriceModel CreateCatalogModel(string itemId, string parentItemId = null, string associationType = null, bool forcedActive = false, ItemResponseGroups responseGroups = ItemResponseGroups.ItemLarge, ItemDisplayOptions display = ItemDisplayOptions.ItemLarge, bool byItemCode = false) { var dbItem = CatalogClient.GetItem(itemId, responseGroups, UserHelper.CustomerSession.CatalogId, bycode: byItemCode); if (dbItem != null) { if (dbItem.IsActive || forcedActive) { PriceModel priceModel = null; PropertySet propertySet = null; //ItemRelation[] variations = null; ItemAvailabilityModel itemAvaiability = null; if (display.HasFlag(ItemDisplayOptions.ItemPropertySets)) { propertySet = CatalogClient.GetPropertySet(dbItem.PropertySetId); //variations = CatalogClient.GetItemRelations(itemId); } var itemModel = CreateItemModel(dbItem, propertySet); if (display.HasFlag(ItemDisplayOptions.ItemAvailability)) { var fulfillmentCenter = UserHelper.StoreClient.GetCurrentStore().FulfillmentCenterId; var availability = CatalogClient.GetItemAvailability(dbItem.ItemId, fulfillmentCenter); itemAvaiability = new ItemAvailabilityModel(availability); } if (display.HasFlag(ItemDisplayOptions.ItemPrice)) { var lowestPrice = PriceListClient.GetLowestPrice(dbItem.ItemId, itemAvaiability != null ? itemAvaiability.MinQuantity : 1); var outlines = OutlineBuilder.BuildCategoryOutline(CatalogClient.CustomerSession.CatalogId, dbItem.ItemId); var tags = new Hashtable { { "Outline", outlines.ToString() } }; priceModel = MarketingHelper.GetItemPriceModel(dbItem, lowestPrice, tags); itemModel.CatalogOutlines = outlines; // get the category name if (outlines.Count > 0) { var outline = outlines[0]; if (outline.Categories.Count > 0) { var category = outline.Categories.OfType<Category>().Reverse().FirstOrDefault(); if (category != null) { itemModel.CategoryName = category.Name; } } } } itemModel.ParentItemId = parentItemId; return string.IsNullOrEmpty(associationType) ? new CatalogItemWithPriceModel(itemModel, priceModel, itemAvaiability) : new AssociatedCatalogItemWithPriceModel(itemModel, priceModel, itemAvaiability, associationType); } } return null; }