Exemplo n.º 1
0
        public static IEnumerable <ProductESalesEntry> GetProductEntries(IEnumerable <Result.Product> products, ResponseGroup responseGroup = DefaultResponseGroup)
        {
            products = products.ToList();
            var entryResponseGroup = new CatalogEntryResponseGroup(responseGroup);
            var entries            = CatalogContext.Current.GetCatalogEntries(products
                                                                              .SelectMany(p => new[] { int.Parse(p.GetValue("_id")) }
                                                                                          .Concat(p.VariantList.EmptyIfNull().Select(v => int.Parse(v.GetValue("_id")))))
                                                                              .ToArray(),
                                                                              false, new TimeSpan(), entryResponseGroup)
                                     .Entry
                                     .EmptyIfNull()
                                     .ToDictionary(e => e.CatalogEntryId, e => e);

            return(products.Select(p => new ProductESalesEntry(
                                       entries[int.Parse(p.GetValue("_id"))],
                                       double.Parse(p.GetValue("proportion", "0")),
                                       p.Ticket,
                                       p.GetValue("_outline", "").Split("|", StringSplitOptions.RemoveEmptyEntries),
                                       p.VariantList.EmptyIfNull()
                                       .Select(v => new ESalesEntry(
                                                   entries[int.Parse(v.GetValue("_id"))],
                                                   double.Parse(v.GetValue("proportion", "0")),
                                                   v.Ticket,
                                                   v.GetValue("_outline", "").Split("|", StringSplitOptions.RemoveEmptyEntries),
                                                   v.ToDictionary(a => a.Name, a => a.Value)
                                                   )),
                                       p.ToDictionary(a => a.Name, a => a.Value))));
        }
        /// <summary>
        /// Get entry row from a line item
        /// </summary>
        /// <param name="lineItem">line item</param>
        protected static CatalogEntryDto.CatalogEntryRow GetEntryRowForLineItem(LineItem lineItem)
        {
            var responseGroup = new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.Variations);

            CatalogEntryDto entryDto = CatalogContext.Current.GetCatalogEntryDto(lineItem.Code, responseGroup);

            return(entryDto.CatalogEntry.FirstOrDefault());
        }
Exemplo n.º 3
0
        /// <summary>
        /// Pre processes item record adding additional LineItems if needed.
        /// </summary>
        /// <param name="order">The order.</param>
        /// <param name="record">The record.</param>
        private void PreProcessItemRecord(OrderGroup order, PromotionItemRecord record)
        {
            // We do special logic for the gift promotion reward
            if (record.PromotionReward is GiftPromotionReward)
            {
                // Check if item already in the cart, if not add
                if (((GiftPromotionReward)record.PromotionReward).AddStrategy == GiftPromotionReward.Strategy.AddWhenNeeded)
                {
                    // We assume that all affected entries are the gifts that need to be added to the cart
                    foreach (PromotionEntry entry in record.AffectedEntriesSet.Entries)
                    {
                        LineItem giftLineItem = FindGiftLineItemInOrder(order, entry.CatalogEntryCode, record);

                        if (!IsOrderHaveSpecifiedGiftPromotion(order, record))
                        {
                            // Didn't find, add it
                            if (giftLineItem == null)
                            {
                                // we should some kind of delegate or common implementation here so we can use the same function in both discount and front end
                                CatalogEntryResponseGroup responseGroup = new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.Variations);
                                Entry catEntry = CatalogContext.Current.GetCatalogEntry(entry.CatalogEntryCode, responseGroup);
                                giftLineItem = AddNewGiftLineItemToOrder(order, catEntry, entry.Quantity);
                                AddGiftItemToAShipment(giftLineItem, giftLineItem.Parent.LineItems.Count - 1);
                                CatalogEntryDto entryDto = CatalogContext.Current.GetCatalogEntryDto(giftLineItem.Code, responseGroup);
                                CatalogEntryDto.CatalogEntryRow entryRow = entryDto.CatalogEntry[0];
                                Money?price = GetItemPrice(entryRow, giftLineItem, CustomerContext.Current.CurrentContact);
                                giftLineItem.ListPrice   = price.HasValue ? price.Value.Amount : 0m;
                                giftLineItem.PlacedPrice = giftLineItem.ListPrice;
                                // populate inventory information for giftLineItem
                                var aggregateInventory = ServiceLocator.Current.GetInstance <IInventoryService>().QueryByEntry(new [] { entryRow.Code });
                                foreach (var inventoryRecord in aggregateInventory)
                                {
                                    PopulateInventoryInfo(inventoryRecord, giftLineItem);
                                }
                            }
                            else
                            {
                                giftLineItem.Quantity = Math.Max(entry.Quantity, giftLineItem.Quantity);

                                var index = giftLineItem.Parent.LineItems.IndexOf(giftLineItem);

                                if (!giftLineItem.Parent.Shipments.SelectMany(x => x.LineItemIndexes).Contains(index.ToString()))
                                {
                                    AddGiftItemToAShipment(giftLineItem, index);
                                }
                            }
                        }
                        else
                        {
                            entry.Quantity = giftLineItem != null?Math.Min(entry.Quantity, giftLineItem.Quantity) : entry.Quantity;
                        }
                        entry.Owner        = giftLineItem;
                        entry.CostPerEntry = giftLineItem != null ? giftLineItem.ListPrice : 0m;
                    }
                }
            }
        }
Exemplo n.º 4
0
        public IEnumerable <CatalogEntryDto.VariationRow> GetVariations(int productId)
        {
            ICatalogSystem            catalog          = EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance <ICatalogSystem>();
            CatalogEntryResponseGroup responseGroup    = new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull);
            CatalogEntryDto           variationEntries = catalog.GetCatalogEntriesDto(productId,
                                                                                      string.Empty,
                                                                                      string.Empty,
                                                                                      responseGroup);

            return(variationEntries.Variation.ToList());
        }
        private void InitDataSource()
        {
            CatalogSearchParameters pars = new CatalogSearchParameters();

            // language filter
            pars.Language = ListLanguages.SelectedValue;

            // catalog filter
            //CatalogDto dto = CatalogContext.Current.GetCatalogDto();
            //foreach (CatalogDto.CatalogRow row in dto.Catalog.Rows)
            //{
            //    pars.CatalogNames.Add(row.Name);
            //}
            if (ListCatalogs.SelectedValue == "[all]")
            {
                foreach (ListItem item in ListCatalogs.Items)
                {
                    if (item.Value == "[all]")
                    {
                        continue;
                    }

                    pars.CatalogNames.Add(item.Value);
                }
            }
            else if (ListCatalogs.SelectedIndex >= 0)            // selected catalogs
            {
                for (int iTmp = 0; iTmp < ListCatalogs.Items.Count; iTmp++)
                {
                    ListItem li = ListCatalogs.Items[iTmp];
                    if (li.Selected)
                    {
                        pars.CatalogNames.Add(li.Value);
                    }
                }
            }
            pars.FreeTextSearchPhrase = tbKeywords.Text;
            CatalogSearchOptions opts = new CatalogSearchOptions();

            opts.RecordsToRetrieve = Int32.MaxValue;
            opts.Namespace         = "Mediachase.Commerce.Catalog";
            opts.StartingRecord    = 0;
            opts.ReturnTotalCount  = true;
            CatalogEntryResponseGroup respgroup = new CatalogEntryResponseGroup();
            int             totalRecordsCount   = 0;
            CatalogEntryDto entries             = CatalogContext.Current.FindItemsDto(pars, opts, ref totalRecordsCount, respgroup);

            if (totalRecordsCount > 0)
            {
                lbSource.DataSource = entries.CatalogEntry.Rows;
            }
        }
Exemplo n.º 6
0
        public int GetProductIdFromCode(string code)
        {
            ICatalogSystem            catalog       = EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance <ICatalogSystem>();
            CatalogEntryResponseGroup responseGroup = new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryInfo);
            CatalogEntryDto           entryDto      = catalog.GetCatalogEntryDto(code, responseGroup);

            if (entryDto == null || entryDto.CatalogEntry.Rows.Count == 0)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            return(entryDto.CatalogEntry[0].CatalogEntryId);
        }
Exemplo n.º 7
0
        public CatalogEntryDto Get(int productId)
        {
            ICatalogSystem            catalog       = EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance <ICatalogSystem>();
            CatalogEntryResponseGroup responseGroup = new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull);
            CatalogEntryDto           entryDto      = catalog.GetCatalogEntryDto(productId, responseGroup);

            if (entryDto == null || entryDto.CatalogEntry.Rows.Count == 0)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            return(entryDto);
        }
        private static CatalogEntryDto.CatalogEntryRow GetEntryRowForLineItem(LineItem lineItem)
        {
            CatalogEntryDto.CatalogEntryRow retVal = null;
            // Remove cache before proceeding
            var responseGroup = new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull);
            string cacheKey = CatalogCache.CreateCacheKey("catalogentry", responseGroup.CacheKey, lineItem.CatalogEntryId.ToString());
            CatalogCache.Remove(cacheKey);

            // Now get the entry
            CatalogEntryDto entryDto = CatalogContext.Current.GetCatalogEntryDto(lineItem.CatalogEntryId, responseGroup);
            if (entryDto != null)
            {
                retVal = entryDto.CatalogEntry.FirstOrDefault();
            }

            return retVal;
        }
Exemplo n.º 9
0
        private static CatalogEntryDto.CatalogEntryRow GetEntryRowForLineItem(LineItem lineItem)
        {
            CatalogEntryDto.CatalogEntryRow retVal = null;
            // Remove cache before proceeding
            var    responseGroup = new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull);
            string cacheKey      = CatalogCache.CreateCacheKey("catalogentry", responseGroup.CacheKey, lineItem.CatalogEntryId.ToString());

            CatalogCache.Remove(cacheKey);

            // Now get the entry
            CatalogEntryDto entryDto = CatalogContext.Current.GetCatalogEntryDto(lineItem.CatalogEntryId, responseGroup);

            if (entryDto != null)
            {
                retVal = entryDto.CatalogEntry.FirstOrDefault();
            }

            return(retVal);
        }
Exemplo n.º 10
0
        private List <ProductInfo> BuildProductVariationRelations(Dictionary <int, CatalogEntryDto.CatalogEntryRow> catalogEntryRows, ICatalogSystem catalog)
        {
            List <ProductInfo>        productsAndVariations = new List <ProductInfo>();
            CatalogEntryResponseGroup variatonRespGroup     =
                new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryInfo);

            // Build product -> variation hierarchy
            foreach (KeyValuePair <int, CatalogEntryDto.CatalogEntryRow> keyValue in catalogEntryRows)
            {
                CatalogEntryDto.CatalogEntryRow entryRow = keyValue.Value;
                if (string.Compare(entryRow.ClassTypeId, "Product", StringComparison.InvariantCultureIgnoreCase) == 0)
                {
                    ProductInfo productInfo = new ProductInfo
                    {
                        EntryRow       = entryRow,
                        CatalogEntryId = keyValue.Key,
                        Code           = entryRow.Code,
                        Name           = entryRow.Name
                    };

                    // Now load all related variations manually
                    CatalogEntryDto variationEntries = catalog.GetCatalogEntriesDto(keyValue.Key, string.Empty, string.Empty,
                                                                                    variatonRespGroup);

                    foreach (CatalogEntryDto.CatalogEntryRow variationRow in variationEntries.CatalogEntry)
                    {
                        if (catalogEntryRows.ContainsKey(variationRow.CatalogEntryId))
                        {
                            productInfo.Variations.Add(catalogEntryRows[variationRow.CatalogEntryId]);
                        }
                    }

                    // Only add if we have a product with one or more variations
                    if (productInfo.Variations.Count > 0)
                    {
                        productsAndVariations.Add(productInfo);
                    }
                }
            }
            return(productsAndVariations);
        }
Exemplo n.º 11
0
        private static Entries GetEntries(string searchText, string classType, MarketId marketId, string languageName, int startIndex, int pageSize, out int count)
        {
            var helper = SearchFilterHelper.Current;
            var group  = new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull);
            CatalogEntrySearchCriteria criteria = helper.CreateSearchCriteria(searchText, CatalogEntrySearchCriteria.DefaultSortOrder);

            criteria.RecordsToRetrieve = pageSize;
            criteria.StartingRecord    = startIndex;

            //class type
            if (classType != null)
            {
                criteria.ClassTypes.Add(classType);
            }

            criteria.Locale          = languageName;
            criteria.MarketId        = marketId;
            criteria.IncludeInactive = false;

            while (searchText.StartsWith("*") || searchText.StartsWith("?"))
            {
                searchText = searchText.Substring(1);
            }
            criteria.SearchPhrase = searchText;

            try
            {
                return(helper.SearchEntries(criteria, out count, @group, true, new TimeSpan(0, 10, 0)));
            }
            catch (Exception ex)
            {
                if (ex is StackOverflowException || ex is OutOfMemoryException)
                {
                    throw;
                }

                count = 0;
                return(new Entries());
            }
        }
Exemplo n.º 12
0
        public IEnumerable <CatalogEntryDto.VariationRow> GetVariations(string productCode)
        {
            ICatalogSystem catalog = EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance <ICatalogSystem>();

            CatalogEntryDto product = Get(productCode);

            if (product.CatalogEntry != null && product.CatalogEntry.Rows.Count > 0)
            {
                CatalogEntryResponseGroup responseGroup = new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull);
                int productId = product.CatalogEntry[0].CatalogEntryId;
                // Need to call this overload due to a bug, which I cannot recall at the moment
                CatalogEntryDto variationEntries = catalog.GetCatalogEntriesDto(productId,
                                                                                string.Empty,
                                                                                string.Empty,
                                                                                responseGroup);

                // variationEntries.Variation[0]

                return(variationEntries.Variation.ToList());
            }
            return(null);
        }
Exemplo n.º 13
0
 /// <summary>
 /// Gets the catalog entries by node dto.
 /// </summary>
 /// <param name="catalogName">Name of the catalog.</param>
 /// <param name="parentNodeCode">The parent node code.</param>
 /// <param name="responseGroup">The response group.</param>
 /// <returns></returns>
 public CatalogEntryDto GetCatalogEntriesByNodeDto(string catalogName, string parentNodeCode, CatalogEntryResponseGroup responseGroup)
 {
     return(CatalogEntryManager.GetCatalogEntriesByCatalogDto(catalogName, parentNodeCode, responseGroup));
 }
Exemplo n.º 14
0
 /// <summary>
 /// Gets the catalog entries dto.
 /// </summary>
 /// <param name="catalogName">Name of the catalog.</param>
 /// <param name="parentNodeId">The parent node id.</param>
 /// <param name="responseGroup">The response group.</param>
 /// <returns></returns>
 public CatalogEntryDto GetCatalogEntriesDto(string catalogName, int parentNodeId, CatalogEntryResponseGroup responseGroup)
 {
     return(CatalogEntryManager.GetCatalogEntriesDto(catalogName, parentNodeId, responseGroup));
 }
Exemplo n.º 15
0
        /// <summary>
        /// Finds the items dto.
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        /// <param name="options">The options.</param>
        /// <param name="recordsCount">The records count.</param>
        /// <param name="responseGroup">The response group.</param>
        /// <returns></returns>
        public CatalogEntryDto FindItemsDto(CatalogSearchParameters parameters, CatalogSearchOptions options, ref int recordsCount, CatalogEntryResponseGroup responseGroup)
        {
            CatalogSearch search = new CatalogSearch();

            search.SearchOptions    = options;
            search.SearchParameters = parameters;
            return(CatalogEntryManager.FindItemsDto(search, ref recordsCount, responseGroup));
        }
Exemplo n.º 16
0
 /// <summary>
 /// Gets the catalog entries dto.
 /// </summary>
 /// <param name="catalogEntries">The catalog entries.</param>
 /// <param name="responseGroup">The response group.</param>
 /// <returns></returns>
 public CatalogEntryDto GetCatalogEntriesDto(int[] catalogEntries, CatalogEntryResponseGroup responseGroup)
 {
     return(_Proxy.GetCatalogEntriesDto(catalogEntries, false, new TimeSpan(), responseGroup));
 }
Exemplo n.º 17
0
 /// <summary>
 /// Gets the catalog entries.
 /// </summary>
 /// <param name="catalogName">Name of the catalog.</param>
 /// <param name="catalogCode">The catalog code.</param>
 /// <param name="responseGroup">The response group.</param>
 /// <returns></returns>
 public Entries GetCatalogEntries(string catalogName, string catalogCode, CatalogEntryResponseGroup responseGroup)
 {
     return(CatalogEntryManager.GetCatalogEntries(catalogName, catalogCode, responseGroup));
 }
Exemplo n.º 18
0
        private void LoadingExamples(ShirtVariation currentContent)
        {
            // AdminPageController have demo of ReferenceConverter

            #region Catalog

            ContentReference parent = currentContent.ParentLink; //...from "me" as the variation
            // note: in 11 --> more strict

            //var x = base._contentLoader.Get<EntryContentBase>(parent);
            var y = base._contentLoader.Get <NodeContentBase>(parent); // gets the ShirtNodeProxy

            IEnumerable <EntryContentBase> children =
                base._contentLoader.GetChildren <EntryContentBase>(parent);

            IEnumerable <ContentReference> allLinks = currentContent.GetCategories();    // Relations
            IEnumerable <Relation>         nodes    = currentContent.GetNodeRelations(); // older, avoid

            var theType = currentContent.GetOriginalType();                              // handy
            var proxy   = currentContent.GetType();                                      // gives the CastleProxy

            IEnumerable <ContentReference> prodParents    = currentContent.GetParentProducts();
            IEnumerable <ContentReference> parentPackages = currentContent.GetParentPackages();
            IEnumerable <ContentReference> allParents     = currentContent.GetParentEntries(); // newer

            IMarket market     = _currentMarket.GetCurrentMarket();                            // Gets "DEFAULT" if not "custom"
            bool    available  = currentContent.IsAvailableInMarket(market.MarketId);          // if we want to know about another market
            bool    available2 = currentContent.IsAvailableInCurrentMarket();

            //ISecurityDescriptor sec = currentContent.GetSecurityDescriptor();

            CatalogEntryResponseGroup respG = new CatalogEntryResponseGroup(
                CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull);

            // Finally in 12 we get squiggles :)
            // old school, not needed after 9.19 ... avoid.
            // ...this is why we have the extension method
            //Mediachase.Commerce.Catalog.Objects.Entry entry =
            //    currentContent.LoadEntry(); // Consider RG

            // the IoC-way to get the above, but use the .ctor not do like this...
            ICatalogSystem catSys = ServiceLocator.Current.GetInstance <ICatalogSystem>();
            // catSys

            //Entry shouldNotUseThis = catSys.GetCatalogEntry(2, respG);
            //var p = shouldNotUseThis.PriceValues; // still populating from price-service, from ECF R3

            // native ECF, just to have a look, still used a lot ... can be handy
            var entryDto = CatalogContext.Current.GetCatalogEntryDto // singular
                               (currentContent.Code, respG);
            var x = entryDto.SalePrice;                              // not used anymore, zero prices back

            // used a lot previously, in combination with the search provider model
            // we can use "search" to easily get an array of "ints" back.
            var entryDto2 = CatalogContext.Current.GetCatalogEntriesDto // Plural, check the overloads
                                (new int[] { 2, 3, 4, 5, 6 }, respG);

            #endregion


            #region Orders

            var p0 = OrderContext.Current.FindActiveOrders();                                       // InProgress & Partially shipped
            //OrderContext.Current.FindPurchaseOrders(); // Not fun... ref Shannons blog (carts too)
            var p1 = OrderContext.Current.FindPurchaseOrdersByStatus(OrderStatus.AwaitingExchange); // array of statuses as arg
            var p2 = OrderContext.Current.GetPurchaseOrders(new Guid());                            // ContactGuid
            var p3 = OrderContext.Current.GetPurchaseOrder(-1);                                     // TrackingNo or DB-PK

            var po0 = _orderRepository.Load();                                                      // all for current user - only POs
            var po1 = _orderRepository.Load(CustomerContext.Current.CurrentContactId);              // Only POs
            var po2 = _orderRepository.Load(CustomerContext.Current.CurrentContactId, "WishList");
            var po3 = _orderRepository.Load <ICart>();
            var po4 = _orderRepository.Load <IPurchaseOrder>(21);

            #endregion
        }
Exemplo n.º 19
0
 /// <summary>
 /// Gets the catalog entries dto.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="entryType">Type of the entry.</param>
 /// <param name="responseGroup">The response group.</param>
 /// <returns></returns>
 public CatalogEntryDto GetCatalogEntriesDto(string name, string entryType, CatalogEntryResponseGroup responseGroup)
 {
     return(CatalogEntryManager.GetCatalogEntriesDto(name, entryType, responseGroup));
 }
Exemplo n.º 20
0
 /// <summary>
 /// Gets the catalog entries.
 /// </summary>
 /// <param name="catalogName">Name of the catalog.</param>
 /// <param name="catalogNodeCode">The catalog node code.</param>
 /// <param name="responseGroup">The response group.</param>
 /// <returns></returns>
 public Entries GetCatalogEntries(string catalogName, string catalogNodeCode, CatalogEntryResponseGroup responseGroup)
 {
     return(_Proxy.GetCatalogEntries(catalogName, catalogNodeCode, responseGroup));
 }
        /// <summary>
        /// Pre processes item record adding additional LineItems if needed.
        /// </summary>
        /// <param name="order">The order.</param>
        /// <param name="record">The record.</param>
        private void PreProcessItemRecord(OrderGroup order, PromotionItemRecord record)
        {
            // We do special logic for the gift promotion reward
            if (record.PromotionReward is GiftPromotionReward)
            {
                // Check if item already in the cart, if not add
                if (((GiftPromotionReward)record.PromotionReward).AddStrategy == GiftPromotionReward.Strategy.AddWhenNeeded)
                {
                    // We assume that all affected entries are the gifts that need to be added to the cart
                    foreach (PromotionEntry entry in record.AffectedEntriesSet.Entries)
                    {
                        LineItem giftLineItem = FindGiftLineItemInOrder(order, entry.CatalogEntryCode, record);

                        if (!IsOrderHaveSpecifiedGiftPromotion(order, record))
                        {
                            // Didn't find, add it
                            if (giftLineItem == null)
                            {
                                // we should some kind of delegate or common implementation here so we can use the same function in both discount and front end
                                CatalogEntryResponseGroup responseGroup = new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.Variations);
                                Entry catEntry = CatalogContext.Current.GetCatalogEntry(entry.CatalogEntryCode, responseGroup);
                                giftLineItem = AddNewGiftLineItemToOrder(order, catEntry, entry.Quantity);
                                AddGiftItemToAShipment(giftLineItem);
                                CatalogEntryDto entryDto = CatalogContext.Current.GetCatalogEntryDto(giftLineItem.Code, responseGroup);
                                CatalogEntryDto.CatalogEntryRow entryRow = entryDto.CatalogEntry[0];
                                Money? price = GetItemPrice(entryRow, giftLineItem, CustomerContext.Current.CurrentContact);
                                giftLineItem.ListPrice = price.HasValue ? price.Value.Amount : 0m;
                                giftLineItem.PlacedPrice = giftLineItem.ListPrice;
                                // populate inventory information for giftLineItem
                                IWarehouseInventory aggregateInventory = ServiceLocator.Current.GetInstance<IWarehouseInventoryService>().GetTotal(new CatalogKey(entryRow));
                                PopulateInventoryInfo(aggregateInventory, giftLineItem);
                            }
                            else
                            {
                                giftLineItem.Quantity = Math.Max(entry.Quantity, giftLineItem.Quantity);
                            }
                        }
                        else
                        {
                            entry.Quantity = giftLineItem != null ? Math.Min(entry.Quantity, giftLineItem.Quantity) : entry.Quantity;
                        }
                        entry.Owner = giftLineItem;
                        entry.CostPerEntry = giftLineItem != null ? giftLineItem.ListPrice : 0m;
                    }
                }
            }
        }
        /// <summary>
        /// Binds the results.
        /// </summary>
        private void BindResults(bool list)
        {
            SearchSort sortObject = CatalogEntrySearchCriteria.DefaultSortOrder;
            //string sort = SortBy.SelectedValue;
            //if (!String.IsNullOrEmpty(sort))
            //{
            //    if (sort.Equals("name", StringComparison.OrdinalIgnoreCase))
            //        sortObject = new SearchSort("displayname");
            //    else if (sort.Equals("plh", StringComparison.OrdinalIgnoreCase))
            //        sortObject =
            //            new SearchSort(String.Format("saleprice{0}", SiteContext.Current.CurrencyCode).ToLower());
            //    else if (sort.Equals("phl", StringComparison.OrdinalIgnoreCase))
            //        sortObject =
            //            new SearchSort(String.Format("saleprice{0}", SiteContext.Current.CurrencyCode).ToLower(), true);
            //}

            var group = new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull);
            SearchFilterHelper helper = SearchFilterHelper.Current;
            CatalogEntrySearchCriteria criteria = helper.CreateSearchCriteria("", sortObject);
            //AddNodesToCriteria(criteria);
            criteria.RecordsToRetrieve = 25;
            criteria.StartingRecord = _startRowIndex;
            criteria.ClassTypes.Add("Product");

            var searchManager = new SearchManager(AppContext.Current.ApplicationName);
            try
            {
                var results = searchManager.Search(criteria);
                if (results == null)
                    return;

                var resultIndexes = results.GetKeyFieldValues<int>();
                var entries = CatalogContext.Current.GetCatalogEntries(resultIndexes, group);
                if (entries.Entry != null)
                {
                    var ds = CreateDataSource(entries, results.TotalCount);
                    if (!list)
                    {
                        EntriesList.DataSource = ds;
                        EntriesList.DataBind();
                        EntriesList.Visible = true;
                        listView.Visible = false;
                    }
                    else
                    {
                        listView.DataSource = ds;
                        listView.DataBind();
                        EntriesList.Visible = false;
                        listView.Visible = true;
                    }

                    if (results.TotalCount < 25)
                    {
                        DataPager3.Visible = false;
                    }
                }

                _filters = helper.SelectedFilters;
                _facets = results.FacetGroups;

                if (_filters != null && _filters.Length > 0)
                {
                    ActiveFilterList.DataSource = _filters;
                    ActiveFilterList.DataBind();
                    ActiveFilterList.Visible = true;
                }
                else
                {
                    ActiveFilterList.Visible = false;
                }

                if (_facets != null && _facets.Length > 0)
                {
                    FilterList.Visible = true;
                    FilterList.DataSource = _facets;
                    FilterList.DataBind();
                }
                else
                {
                    FilterList.Visible = false;
                }

            }
            catch (Exception ex)
            {
                LogManager.GetLogger(GetType()).Error(ex.Message, ex);
            }
        }
Exemplo n.º 23
0
 /// <summary>
 /// Gets the catalog entries dto.
 /// </summary>
 /// <param name="catalogId">The catalog id.</param>
 /// <param name="responseGroup">The response group.</param>
 /// <returns></returns>
 public CatalogEntryDto GetCatalogEntriesDto(int catalogId, CatalogEntryResponseGroup responseGroup)
 {
     return(CatalogEntryManager.GetCatalogEntriesDto(catalogId, responseGroup));
 }
Exemplo n.º 24
0
 /// <summary>
 /// Gets the catalog entry dto.
 /// </summary>
 /// <param name="catalogEntryCode">The catalog entry code.</param>
 /// <param name="responseGroup">The response group.</param>
 /// <returns></returns>
 public CatalogEntryDto GetCatalogEntryDto(string catalogEntryCode, CatalogEntryResponseGroup responseGroup)
 {
     return(CatalogEntryManager.GetCatalogEntryDto(catalogEntryCode, responseGroup));
 }
Exemplo n.º 25
0
 /// <summary>
 /// Gets the catalog entries dto.
 /// </summary>
 /// <param name="parentEntryId">The parent entry id.</param>
 /// <param name="entryType">Type of the entry.</param>
 /// <param name="relationType">Type of the relation.</param>
 /// <param name="responseGroup">The response group.</param>
 /// <returns></returns>
 public CatalogEntryDto GetCatalogEntriesDto(int parentEntryId, string entryType, string relationType, CatalogEntryResponseGroup responseGroup)
 {
     return(CatalogEntryManager.GetCatalogEntriesDto(parentEntryId, entryType, relationType, responseGroup));
 }
Exemplo n.º 26
0
 /// <summary>
 /// Gets the catalog entry.
 /// </summary>
 /// <param name="code">The code.</param>
 /// <param name="responseGroup">The response group.</param>
 /// <returns></returns>
 public Entry GetCatalogEntry(string code, CatalogEntryResponseGroup responseGroup)
 {
     return(CatalogEntryManager.GetCatalogEntry(code, responseGroup));
 }
Exemplo n.º 27
0
 /// <summary>
 /// Gets the associated catalog entries dto.
 /// </summary>
 /// <param name="parentEntryCode">The parent entry code.</param>
 /// <param name="associationName">Name of the association.</param>
 /// <param name="responseGroup">The response group.</param>
 /// <returns></returns>
 public CatalogEntryDto GetAssociatedCatalogEntriesDto(string parentEntryCode, string associationName, CatalogEntryResponseGroup responseGroup)
 {
     return(CatalogEntryManager.GetAssociatedCatalogEntriesDto(parentEntryCode, associationName, responseGroup));
 }
        /// <summary>
        /// Get entry row from a line item
        /// </summary>
        /// <param name="lineItem">line item</param>
        protected static CatalogEntryDto.CatalogEntryRow GetEntryRowForLineItem(LineItem lineItem)
        {
            var responseGroup = new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.Variations);

            CatalogEntryDto entryDto = CatalogContext.Current.GetCatalogEntryDto(lineItem.Code, responseGroup);
            return entryDto.CatalogEntry.FirstOrDefault();
        }
Exemplo n.º 29
0
 /// <summary>
 /// Gets the catalog entry.
 /// </summary>
 /// <param name="catalogEntryId">The catalog entry id.</param>
 /// <param name="responseGroup">The response group.</param>
 /// <returns></returns>
 public Entry GetCatalogEntry(int catalogEntryId, CatalogEntryResponseGroup responseGroup)
 {
     return(CatalogEntryManager.GetCatalogEntry(catalogEntryId, responseGroup));
 }
Exemplo n.º 30
0
 /// <summary>
 /// Gets the catalog entries dto.
 /// </summary>
 /// <param name="catalogEntries">The catalog entries.</param>
 /// <param name="responseGroup">The response group.</param>
 /// <returns></returns>
 public Entries GetCatalogEntries(int[] catalogEntries, CatalogEntryResponseGroup responseGroup)
 {
     return(CatalogEntryManager.GetCatalogEntries(catalogEntries, false, new TimeSpan(), responseGroup));
 }
Exemplo n.º 31
0
 /// <summary>
 /// Gets the catalog entry by URI dto.
 /// </summary>
 /// <param name="uri">The URI.</param>
 /// <param name="languageCode">The language code.</param>
 /// <param name="responseGroup">The response group.</param>
 /// <returns></returns>
 public Entry GetCatalogEntryByUri(string uri, string languageCode, CatalogEntryResponseGroup responseGroup)
 {
     return(CatalogEntryManager.GetCatalogEntryByUri(uri, languageCode, responseGroup));
 }
Exemplo n.º 32
0
        /// <summary>
        /// Finds the items.
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        /// <param name="options">The options.</param>
        /// <param name="responseGroup">The response group.</param>
        /// <returns></returns>
        public Entries FindItems(CatalogSearchParameters parameters, CatalogSearchOptions options, CatalogEntryResponseGroup responseGroup)
        {
            CatalogSearch search = new CatalogSearch();

            search.SearchOptions    = options;
            search.SearchParameters = parameters;
            return(CatalogEntryManager.FindItems(search, responseGroup));
        }
Exemplo n.º 33
0
 /// <summary>
 /// Gets the catalog entries dto.
 /// </summary>
 /// <param name="catalogEntries">The catalog entries.</param>
 /// <param name="cacheResults">if set to <c>true</c> [cache results].</param>
 /// <param name="cacheTimeout">The cache timeout.</param>
 /// <param name="responseGroup">The response group.</param>
 /// <returns></returns>
 public CatalogEntryDto GetCatalogEntriesDto(int[] catalogEntries, bool cacheResults, TimeSpan cacheTimeout, CatalogEntryResponseGroup responseGroup)
 {
     return(CatalogEntryManager.GetCatalogEntriesDto(catalogEntries, cacheResults, cacheTimeout, responseGroup));
 }
Exemplo n.º 34
0
 /// <summary>
 /// Gets the catalog entries.
 /// </summary>
 /// <param name="catalogEntries">The catalog entries.</param>
 /// <param name="cacheResults">if set to <c>true</c> [cache results].</param>
 /// <param name="cacheTimeout">The cache timeout.</param>
 /// <param name="responseGroup">The response group.</param>
 /// <returns></returns>
 public Entries GetCatalogEntries(int[] catalogEntries, bool cacheResults, TimeSpan cacheTimeout, CatalogEntryResponseGroup responseGroup)
 {
     return(_Proxy.GetCatalogEntries(catalogEntries, cacheResults, cacheTimeout, responseGroup));
 }