Exemplo n.º 1
0
		/// <summary>
		/// Initializes a new instance of the <see cref="SearchController"/> class.
		/// </summary>
		/// <param name="marketing">The marketing.</param>
		/// <param name="priceListClient">The price list client.</param>
		/// <param name="storeClient">The store client.</param>
		/// <param name="catalogClient">The catalog client.</param>
        public SearchController(MarketingHelper marketing, PriceListClient priceListClient, StoreClient storeClient,
                                CatalogClient catalogClient)
        {
            _marketing = marketing;
            _priceListClient = priceListClient;
            _storeClient = storeClient;
            _catalogClient = catalogClient;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="SearchController" /> class.
 /// </summary>
 /// <param name="marketing">The marketing.</param>
 /// <param name="priceListClient">The price list client.</param>
 /// <param name="storeClient">The store client.</param>
 /// <param name="catalogClient">The catalog client.</param>
 /// <param name="searchFilter">The search filter.</param>
 public SearchController(MarketingHelper marketing, PriceListClient priceListClient, StoreClient storeClient,
                         CatalogClient catalogClient, ISearchFilterService searchFilter)
 {
     _marketing = marketing;
     _priceListClient = priceListClient;
     _storeClient = storeClient;
     _catalogClient = catalogClient;
     _searchFilter = searchFilter;
 }
Exemplo n.º 3
0
        /// <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;
        }