Пример #1
0
        private void WalkCatalogNodes(ICatalogSystem catalogSystem, CatalogNodeDto nodes, CatalogDto.CatalogRow catalog, Dictionary <int, CatalogEntryDto.CatalogEntryRow> catalogEntryRows)
        {
            foreach (CatalogNodeDto.CatalogNodeRow node in nodes.CatalogNode)
            {
                CatalogSearchParameters pars    = new CatalogSearchParameters();
                CatalogSearchOptions    options = new CatalogSearchOptions {
                    CacheResults = false
                };
                pars.CatalogNames.Add(catalog.Name);
                pars.CatalogNodes.Add(node.Code);
                //CatalogEntryDto entries = CatalogContext.Current.FindItemsDto(
                //    pars,
                //    options,
                //    ref count,
                //    new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull));
                CatalogEntryDto entries = catalogSystem.GetCatalogEntriesDto(catalog.CatalogId, node.CatalogNodeId,
                                                                             new CatalogEntryResponseGroup(
                                                                                 CatalogEntryResponseGroup.ResponseGroup.CatalogEntryInfo));

                _log.DebugFormat("Entries in Node: {0} (Count: {1})", node.Name, entries.CatalogEntry.Rows.Count);
                foreach (CatalogEntryDto.CatalogEntryRow entry in entries.CatalogEntry)
                {
                    // _log.DebugFormat("{3}: {0} ({1} - {2})", entry.Name, entry.Code, entry.CatalogEntryId, entry.ClassTypeId);
                    if (catalogEntryRows.ContainsKey(entry.CatalogEntryId) == false)
                    {
                        catalogEntryRows.Add(entry.CatalogEntryId, entry);
                    }
                }

                // Get Subnodes
                CatalogNodeDto subNodes = catalogSystem.GetCatalogNodesDto(catalog.CatalogId, node.CatalogNodeId);
                WalkCatalogNodes(catalogSystem, subNodes, catalog, catalogEntryRows);
            }
        }
Пример #2
0
        public void Search_JoinQuery()
        {
            ICatalogSystem system = CatalogContext.Current;

            // Get catalog lists
            CatalogDto catalogs = system.GetCatalogDto();

            foreach (CatalogDto.CatalogRow catalog in catalogs.Catalog)
            {
                string catalogName = catalog.Name;

                // Get Catalog Nodes
                CatalogNodeDto nodes = system.GetCatalogNodesDto(catalogName);
                foreach (CatalogNodeDto.CatalogNodeRow node in nodes.CatalogNode)
                {
                    CatalogSearchParameters pars    = new CatalogSearchParameters();
                    CatalogSearchOptions    options = new CatalogSearchOptions();
                    options.CacheResults = true;

                    pars.CatalogNames.Add(catalogName);
                    pars.CatalogNodes.Add(node.Code);
                    pars.JoinType           = "inner join";
                    pars.Language           = "en-us";
                    pars.JoinSourceTable    = "CatalogEntry";
                    pars.JoinTargetQuery    = "(select distinct ObjectId, DisplayName from CatalogEntryEx) CatalogEntryEx";
                    pars.JoinSourceTableKey = "CatalogEntryId";
                    pars.JoinTargetTableKey = "CatalogEntryEx.ObjectId";
                    pars.OrderByClause      = "CatalogEntryEx.DisplayName";

                    Entries entries = CatalogContext.Current.FindItems(pars, options, new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull));
                }
            }
        }
Пример #3
0
        public void Search_BrowseEntries()
        {
            ICatalogSystem system = CatalogContext.Current;

            // Get catalog lists
            CatalogDto catalogs = system.GetCatalogDto();

            foreach (CatalogDto.CatalogRow catalog in catalogs.Catalog)
            {
                string catalogName = catalog.Name;

                // Get Catalog Nodes
                CatalogNodeDto nodes = system.GetCatalogNodesDto(catalogName);
                foreach (CatalogNodeDto.CatalogNodeRow node in nodes.CatalogNode)
                {
                    CatalogSearchParameters pars    = new CatalogSearchParameters();
                    CatalogSearchOptions    options = new CatalogSearchOptions();
                    options.CacheResults = true;

                    pars.CatalogNames.Add(catalogName);
                    pars.CatalogNodes.Add(node.Code);

                    Entries entries = CatalogContext.Current.FindItems(pars, options, new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull));
                }
            }
        }
Пример #4
0
        public string CreateOrders([FromBody] OrderGeneratorSettings settings)
        {
            Stopwatch tmr = Stopwatch.StartNew();

            _log.DebugFormat("Start Creating {0} orders", settings.NumberOfOrdersToGenerate);

            // We need all Products with variations
            ICatalogSystem catalog = EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance <ICatalogSystem>();
            Dictionary <int, CatalogEntryDto.CatalogEntryRow> catalogEntryRows = new Dictionary <int, CatalogEntryDto.CatalogEntryRow>();

            WalkCatalog(catalog, catalogEntryRows);

            long elapsedMilliseconds = tmr.ElapsedMilliseconds;

            _log.DebugFormat("Reading {0} entries took {1}ms", catalogEntryRows.Count, elapsedMilliseconds);

            // Build the relationship between the products and their variations
            List <ProductInfo> productsAndVariations = BuildProductVariationRelations(catalogEntryRows, catalog);

            _log.DebugFormat("There are {0} products (with variations)", productsAndVariations.Count);

            // Load All customers, we need to distribute the orders among them
            CustomerController cc        = new CustomerController();
            List <Customer>    customers = cc.Get().ToList();

            _log.DebugFormat("There are {0} customers to distribute {1} orders on", productsAndVariations.Count, customers.Count);

            // Create them orders - this is where the bulk of the job is taking place
            string returnInfo = CreateOrdersForCustomers(settings, productsAndVariations, customers);

            tmr.Stop();
            return(returnInfo);
        }
Пример #5
0
        /// <summary>
        /// Gets the total records.
        /// </summary>
        /// <returns></returns>
        private int GetTotalRecords()
        {
            int            numRecords = 0;
            ICatalogSystem system     = CatalogContext.Current;

            // Get catalog lists
            CatalogDto catalogs = system.GetCatalogDto();

            foreach (CatalogDto.CatalogRow catalog in catalogs.Catalog)
            {
                string catalogName = catalog.Name;

                // Get Catalog Nodes
                CatalogSearchParameters pars    = new CatalogSearchParameters();
                CatalogSearchOptions    options = new CatalogSearchOptions();
                options.CacheResults = false;
                pars.CatalogNames.Add(catalogName);
                options.RecordsToRetrieve = 1;
                options.StartingRecord    = 0;

                int             totalCount = 0;
                CatalogEntryDto entryDto   = CatalogContext.Current.FindItemsDto(pars, options, ref totalCount);
                numRecords += totalCount;
            }

            return(numRecords);
        }
Пример #6
0
        public void CatalogSystem_UnitTest_SearchEntries()
        {
            ICatalogSystem system = CatalogContext.Current;

            // Get catalog lists
            CatalogDto catalogs = system.GetCatalogDto();

            foreach (CatalogDto.CatalogRow catalog in catalogs.Catalog)
            {
                string catalogName = catalog.Name;

                // Get Catalog Nodes
                CatalogSearchParameters pars    = new CatalogSearchParameters();
                CatalogSearchOptions    options = new CatalogSearchOptions();


                // Search phrase arbitrary
                pars.FreeTextSearchPhrase = "policy";

                // Set language
                pars.Language = "en-us";

                pars.CatalogNames.Add(catalogName);

                Entries entries = CatalogContext.Current.FindItems(pars, options, new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull));

                // Meaningless assert - to be replaced with appropriate assert once the problem with search is figured out
                Assert.IsTrue(entries.TotalResults == entries.TotalResults);
                Console.WriteLine("Number of entries matching \"{0}\" in the {1} catalog: {2}", pars.FreeTextSearchPhrase, catalogName, entries.TotalResults);
            }
            //Assert.Inconclusive("Verify the correctness of this test method.");
        }
 public FindProductUiSearchProvider(LocalizationService localizationService, ICatalogSystem catalogSystem)
     : this(localizationService,
            catalogSystem,
            ServiceLocator.Current.GetInstance <ReferenceConverter>(),
            ServiceLocator.Current.GetInstance <IContentLoader>())
 {
 }
Пример #8
0
        protected void PrimeCacheImpl()
        {
            ICatalogSystem       catalog            = ServiceLocator.Current.GetInstance <ICatalogSystem>();
            IContentRepository   repository         = ServiceLocator.Current.GetInstance <IContentRepository>();
            ReferenceConverter   referenceConverter = ServiceLocator.Current.GetInstance <ReferenceConverter>();
            CatalogContentLoader contentLoader      = ServiceLocator.Current.GetInstance <CatalogContentLoader>();

            // Get all catalogs
            CatalogDto catalogDto = catalog.GetCatalogDto();

            _log.Debug("Found {0} catalogs. Start iterating.", catalogDto.Catalog.Count);
            foreach (CatalogDto.CatalogRow catalogRow in catalogDto.Catalog)
            {
                _log.Debug("Loading all categories for catalog {0} ({1})", catalogRow.Name, catalogRow.CatalogId);
                // Get all Categories on first level
                CatalogNodes nodes = catalog.GetCatalogNodes(catalogRow.CatalogId,
                                                             new CatalogNodeResponseGroup(CatalogNodeResponseGroup.ResponseGroup.CatalogNodeInfo));
                _log.Debug("Loaded {0} categories using ICatalogSystem", nodes.CatalogNode.Count());
                // Get them as content too
                foreach (CatalogNode node in nodes.CatalogNode)
                {
                    ContentReference nodeReference = referenceConverter.GetContentLink(node.CatalogNodeId, CatalogContentType.CatalogNode, 0);
                    NodeContent      content       = repository.Get <EPiServer.Commerce.Catalog.ContentTypes.NodeContent>(nodeReference);
                    _log.Debug("Loded Category Content: {0}", content.Name);
                    WalkCategoryTree(content, repository, contentLoader, catalog, referenceConverter);
                }
            }
        }
 public FindProductUiSearchProvider(LocalizationService localizationService, ICatalogSystem catalogSystem)
     : this(localizationService, 
            catalogSystem, 
            ServiceLocator.Current.GetInstance<ReferenceConverter>(), 
            ServiceLocator.Current.GetInstance<IContentLoader>())
 {
 }
 public FindProductUiSearchProvider(LocalizationService localizationService, ICatalogSystem catalogSystem, ReferenceConverter referenceConverter, IContentLoader contentLoader)
 {
     _catalogSystem = catalogSystem;
     _localizationService = localizationService;
     _catalogContext = catalogSystem;
     _referenceConverter = referenceConverter;
     _contentLoader = contentLoader;
 }
 public FindProductUiSearchProvider(LocalizationService localizationService, ICatalogSystem catalogSystem, ReferenceConverter referenceConverter, IContentLoader contentLoader)
 {
     _catalogSystem       = catalogSystem;
     _localizationService = localizationService;
     _catalogContext      = catalogSystem;
     _referenceConverter  = referenceConverter;
     _contentLoader       = contentLoader;
 }
Пример #12
0
        protected void WalkCategoryTree(NodeContent node,
                                        IContentRepository repository,
                                        CatalogContentLoader contentLoader,
                                        ICatalogSystem catalog,
                                        ReferenceConverter referenceConverter)
        {
            // ReSharper disable PossibleMultipleEnumeration
            // Get all products
            Stopwatch tmr = Stopwatch.StartNew();
            IEnumerable <EntryContentBase> entries = repository.GetChildren <EPiServer.Commerce.Catalog.ContentTypes.EntryContentBase>(node.ContentLink);

            _log.Debug("Loaded {0} entries in category {1} using IContentRepository in {2}ms",
                       entries.Count(),
                       node.Name,
                       tmr.ElapsedMilliseconds);

            // Load and cache Entry objects. Still a lot of code that uses this
            tmr = Stopwatch.StartNew();
            foreach (EntryContentBase entryAsContent in entries)
            {
                // Load full entry
                int entryId = referenceConverter.GetObjectId(entryAsContent.ContentLink);
                // Catalog Gadget uses info
                //catalog.GetCatalogEntry(entryId,
                //	new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryInfo));
                catalog.GetCatalogEntry(entryId,
                                        new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull));
            }

            // Prime the catalog gadget
            // IEnumerable<IContent> children = repository.GetChildren<IContent>(node.ContentLink, new LanguageSelector("en"), 0, int.MaxValue);
            // _log.Debug("Loaded {0} children", children.Count());

            // .GetDescendents(node.ContentLink);

            tmr.Stop();
            _log.Debug("Loaded {0} entries in category {1} using ICatalogSystem in {2}ms",
                       entries.Count(),
                       node.Name,
                       tmr.ElapsedMilliseconds);

            // Get all products the way it is done in edit mode, but this does not seem to
            // use the cache.
            //int loadedEntries;
            //contentLoader.GetCatalogEntries(node.ContentLink, 0, int.MaxValue, out loadedEntries);
            //_log.Debug("Loaded {0} entries in category {1} using CatalogContentLoader", loadedEntries, node.Name);

            // Get child nodes the same way done by the UI
            IList <CatalogGetChildrenReferenceResult> catalogNodes = contentLoader.GetCatalogNodes(node.ContentLink);

            _log.Debug("Loaded {0} categories in category {1} using CatalogContentLoader", catalogNodes.Count, node.Name);
            foreach (GetChildrenReferenceResult catalogNode in catalogNodes)
            {
                NodeContent childNode = repository.Get <NodeContent>(catalogNode.ContentLink);
                WalkCategoryTree(childNode, repository, contentLoader, catalog, referenceConverter);
            }
            // ReSharper restore PossibleMultipleEnumeration
        }
Пример #13
0
 public IndexBuilder(ICatalogSystem catalogSystem,
                     IPriceService priceService,
                     IInventoryService inventoryService,
                     MetaDataContext metaDataContext,
                     CatalogItemChangeManager catalogItemChangeManager,
                     NodeIdentityResolver nodeIdentityResolver) : base(catalogSystem, priceService, inventoryService, metaDataContext, catalogItemChangeManager, nodeIdentityResolver)
 {
     _catalog = catalogSystem;
 }
Пример #14
0
        protected IEnumerable <int> GetCatalogIds()
        {
            ICatalogSystem catalogSystem = ServiceLocator.Current.GetInstance <ICatalogSystem>();
            CatalogDto     catalogDto    = catalogSystem.GetCatalogDto();

            foreach (CatalogDto.CatalogRow row in catalogDto.Catalog)
            {
                yield return(row.CatalogId);
            }
        }
Пример #15
0
 public SearchController(IContentLoader contentLoader
                         , ReferenceConverter referenceConverter
                         , UrlResolver urlResolver
                         , ICatalogSystem catalogSystem)
 {
     _contentLoader      = contentLoader;
     _referenceConverter = referenceConverter;
     _urlResolver        = urlResolver;
     _catalogSystem      = catalogSystem;
 }
Пример #16
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());
        }
Пример #17
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);
        }
Пример #18
0
 public PromotionEntryService(
     ILinksRepository linksRepository,
     ICatalogSystem catalogSystem,
     IContentLoader contentLoader,
     IWarehouseInventoryService inventoryService,
     IWarehouseRepository warehouseRepository)
 {
     _contentLoader = contentLoader;
     _linksRepository = linksRepository;
     _catalogSystem = catalogSystem;
     _inventoryService = inventoryService;
     _warehouseRepository = warehouseRepository;
 }
Пример #19
0
 public PromotionEntryService(
     ILinksRepository linksRepository,
     ICatalogSystem catalogSystem,
     IContentLoader contentLoader,
     IInventoryService inventoryService,
     IWarehouseRepository warehouseRepository)
 {
     _contentLoader       = contentLoader;
     _linksRepository     = linksRepository;
     _catalogSystem       = catalogSystem;
     _inventoryService    = inventoryService;
     _warehouseRepository = warehouseRepository;
 }
Пример #20
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);
        }
Пример #21
0
        public void Search_Lucene_WithinCatalogsWithSorting()
        {
            ICatalogSystem system = CatalogContext.Current;

            // Get catalog lists
            CatalogDto catalogs = system.GetCatalogDto();

            // Create Entry Criteria
            CatalogEntrySearchCriteria criteria = new CatalogEntrySearchCriteria();

            // Bind default catalogs if none found
            if (criteria.CatalogNames.Count == 0)
            {
                if (catalogs.Catalog.Count > 0)
                {
                    foreach (CatalogDto.CatalogRow row in catalogs.Catalog)
                    {
                        if (row.IsActive && row.StartDate <= FrameworkContext.Current.CurrentDateTime && row.EndDate >= FrameworkContext.Current.CurrentDateTime)
                        {
                            criteria.CatalogNames.Add(row.Name);
                        }
                    }
                }
            }

            // Define phrase we want to search
            criteria.SearchPhrase = "canon";

            // Create a manager
            SearchManager manager = new SearchManager(AppContext.Current.ApplicationName);

            SearchResults results = null;

            // Define sort parameter
            criteria.Sort = new SearchSort("DisplayName");

            // Perform search
            results = manager.Search(criteria);

            Assert.IsTrue(results.TotalCount > 0, "No hits were found in Lucene index.");

            // Get IDs we need
            int[] resultIndexes = results.GetIntResults(0, 10 + 5); // we add padding here to accomodate entries that might have been deleted since last indexing

            // Retrieve actual entry objects, with no caching
            Entries entries = CatalogContext.Current.GetCatalogEntries(resultIndexes, false, new TimeSpan(), new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull));

            entries.TotalResults = results.TotalCount;

            Assert.IsTrue(entries.TotalResults > 0, "No entries were returned from the database.");
        }
Пример #22
0
        protected void WalkCatalog(ICatalogSystem catalogSystem, Dictionary <int, CatalogEntryDto.CatalogEntryRow> catalogEntryRows)
        {
            // Get all catalogs
            CatalogDto catalogs = catalogSystem.GetCatalogDto();

            foreach (CatalogDto.CatalogRow catalog in catalogs.Catalog)
            {
                // string catalogName = catalog.Name;
                int catalogId = catalog.CatalogId;
                // Get Catalog Nodes
                CatalogNodeDto nodes = catalogSystem.GetCatalogNodesDto(catalogId);
                WalkCatalogNodes(catalogSystem, nodes, catalog, catalogEntryRows);
            }
        }
Пример #23
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            ICatalogSystem catalogContext = CatalogContext.Current;
            ProfileContext profileContext = ProfileContext.Current;
            OrderContext   orderContext   = OrderContext.Current;

            List <Alert> alerts = GetAlertsDataSource();

            if (alerts.Count > 0)
            {
                this.AlertsList.DataSource = alerts;
            }
            this.AlertsList.DataBind();
        }
Пример #24
0
 public CatalogIndexer(ICatalogSystem catalogSystem,
                       IPriceService priceService,
                       IPricingService pricingService,
                       IInventoryService inventoryService,
                       MetaDataContext metaDataContext,
                       AssetUrlResolver assetUrlResolver,
                       ILogger logger,
                       CatalogContentService catalogContentService)
     : base(catalogSystem, priceService, inventoryService, metaDataContext)
 {
     _pricingService   = pricingService;
     _assetUrlResolver = assetUrlResolver;
     _log = logger;
     _catalogContentService = catalogContentService;
 }
Пример #25
0
        public void CatalogSystem_UnitTest_BrowseEntries()
        {
            ICatalogSystem system = CatalogContext.Current;

            // Get catalog lists
            CatalogDto catalogs = system.GetCatalogDto();

            // Number of entries in CatalogEntry table
            int entryCount = 0;

            foreach (CatalogDto.CatalogRow catalog in catalogs.Catalog)
            {
                string catalogName = catalog.Name;

                // Get Catalog Nodes
                CatalogNodeDto nodes = system.GetCatalogNodesDto(catalogName);
                foreach (CatalogNodeDto.CatalogNodeRow node in nodes.CatalogNode)
                {
                    CatalogSearchParameters pars    = new CatalogSearchParameters();
                    CatalogSearchOptions    options = new CatalogSearchOptions();
                    options.CacheResults = true;

                    pars.Language = "en-us";

                    pars.CatalogNames.Add(catalogName);
                    pars.CatalogNodes.Add(node.Code);

                    // Test does not seem to be working: entries are mostly returning empty.
                    Entries entries = CatalogContext.Current.FindItems(pars, options, new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull));

                    try
                    {
                        foreach (Entry entry in entries.Entry)
                        {
                            // Something to do? Just looking at entries
                            entryCount++;
                        }
                    }
                    catch (Exception e)
                    {
                        Assert.IsFalse(new NullReferenceException().Equals(e));
                    }
                }
            }
            // As of testing 4/19/09, entryCount incremented 22 times (there are over 1300 entries in the table CatalogEntry)
            Console.WriteLine("Number of entries browsed: {0:d}", entryCount);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Пример #26
0
        public ActionResult Index(StartPage currentPage)
        {
            //get catalog list
            ICatalogSystem  target      = CatalogContext.Current;
            CatalogDto      catalogs    = target.GetCatalogDto();
            List <MyNodeVM> listCatelog = new List <MyNodeVM>();

            foreach (CatalogDto.CatalogRow catalog in catalogs.Catalog)
            {
                listCatelog.Add(new MyNodeVM()
                {
                    CatalogName = catalog.Name
                });
            }
            currentPage.Catelogs = listCatelog;
            return(View(currentPage));
        }
Пример #27
0
 public RestIndexer(
     ICatalogSystem catalogSystem,
     IPriceService priceService,
     IInventoryService inventoryService,
     MetaDataContext metaDataContext,
     CatalogItemChangeManager catalogItemChangeManager,
     NodeIdentityResolver nodeIdentityResolver)
     : base(
         catalogSystem,
         priceService,
         inventoryService,
         metaDataContext,
         catalogItemChangeManager,
         nodeIdentityResolver)
 {
     _url = VirtualPathUtility.AppendTrailingSlash(ConfigurationManager.AppSettings["SearchApiUrl"]);
 }
Пример #28
0
 public CatalogIndexer(ICatalogSystem catalogSystem,
                       IPriceService priceService,
                       IInventoryService inventoryService,
                       MetaDataContext metaDataContext,
                       IContentLoader contentLoader,
                       IPromotionService promotionService,
                       ReferenceConverter referenceConverter,
                       AssetUrlResolver assetUrlResolver,
                       IRelationRepository relationRepository,
                       ILogger logger)
     : base(catalogSystem, priceService, inventoryService, metaDataContext)
 {
     _priceService       = priceService;
     _contentLoader      = contentLoader;
     _promotionService   = promotionService;
     _referenceConverter = referenceConverter;
     _assetUrlResolver   = assetUrlResolver;
     _relationRepository = relationRepository;
     _log = logger;
 }
Пример #29
0
        public void Search_AdvancedFTS()
        {
            ICatalogSystem system = CatalogContext.Current;

            // Get catalog lists
            CatalogDto catalogs = system.GetCatalogDto();

            foreach (CatalogDto.CatalogRow catalog in catalogs.Catalog)
            {
                string catalogName = catalog.Name;

                // Get Catalog Nodes
                CatalogSearchParameters pars    = new CatalogSearchParameters();
                CatalogSearchOptions    options = new CatalogSearchOptions();

                pars.AdvancedFreeTextSearchPhrase = "(\"sweet and savory\" NEAR sauces) OR (\"sweet and savory\" NEAR candies)";
                pars.CatalogNames.Add(catalogName);

                Entries entries = CatalogContext.Current.FindItems(pars, options, new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull));
            }
        }
Пример #30
0
 public CatalogIndexer(ICatalogSystem catalogSystem, 
     IPriceService priceService, 
     IInventoryService inventoryService, 
     MetaDataContext metaDataContext, 
     IContentLoader contentLoader,
     IPromotionService promotionService,
     ReferenceConverter referenceConverter,
     AssetUrlResolver assetUrlResolver,
     IRelationRepository relationRepository,
     AppContextFacade appContext,
     ILogger logger)
     : base(catalogSystem, priceService, inventoryService, metaDataContext)
 {
     _priceService = priceService;
     _contentLoader = contentLoader;
     _promotionService = promotionService;
     _referenceConverter = referenceConverter;
     _assetUrlResolver = assetUrlResolver;
     _relationRepository = relationRepository;
     _appContext = appContext;
     _log = logger;
 }
Пример #31
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);
        }
Пример #32
0
 public CatalogIndexer(
     ICatalogSystem catalogSystem,
     IPriceService priceService,
     IPricingService pricingService,
     IInventoryService inventoryService,
     MetaDataContext metaDataContext,
     CatalogItemChangeManager catalogItemChangeManager,
     NodeIdentityResolver nodeIdentityResolver,
     AssetUrlResolver assetUrlResolver,
     CatalogContentService catalogContentService)
     : base(
         catalogSystem,
         priceService,
         inventoryService,
         metaDataContext,
         catalogItemChangeManager,
         nodeIdentityResolver)
 {
     _pricingService        = pricingService;
     _assetUrlResolver      = assetUrlResolver;
     _catalogContentService = catalogContentService;
     _log = LogManager.GetLogger(typeof(CatalogIndexer));
 }
Пример #33
0
        public ClearCatalogAndModelsResult ClearCatalogAndModels()
        {
            List <string> logList = new List <string>();
            ClearCatalogAndModelsResult result = new ClearCatalogAndModelsResult();

            ICatalogSystem catalogSystem = ServiceLocator.Current.GetInstance <ICatalogSystem>();
            CatalogDto     catalogDto    = catalogSystem.GetCatalogDto();

            foreach (CatalogDto.CatalogRow row in catalogDto.Catalog)
            {
                _log.Debug("Deleting catalog: " + row.Name);
                try
                {
                    CatalogContext.Current.DeleteCatalog(row.CatalogId);
                    result.CatalogsDeleted++;
                }
                catch (Exception e)
                {
                    result.CatalogsFailed++;
                    _log.Error("Failed to delete catalog: " + row.Name, e);
                }
            }

            DeleteAllMetaClasses(true, result);

            // Remove all imported inRiver Resources
            _log.Debug("Deleting inRiver Media Folder");
            DeleteFileFolder("inRiver", result);

            // Cache is invalid now, clear it
            _log.Debug("Clearing Cache");
            ClearCache();

            _log.Debug("Syncing Content Type Models");

            return(result);
        }
Пример #34
0
 public MyPriceService(ICatalogSystem catalogSystem, IChangeNotificationManager changeManager, ISynchronizedObjectInstanceCache objectInstanceCache, CatalogKeyEventBroadcaster broadcaster, IApplicationContext applicationContext)
 {
     _marketService = ServiceLocator.Current.GetInstance<IMarketService>();
     _referenceConverter = ServiceLocator.Current.GetInstance<ReferenceConverter>();
 }
 protected IndexMoreProperties(ICatalogSystem catalogSystem, IPriceService priceService, IInventoryService inventoryService, MetaDataContext metaDataContext, CatalogItemChangeManager catalogItemChangeManager, NodeIdentityResolver nodeIdentityResolver) : base(catalogSystem, priceService, inventoryService, metaDataContext, catalogItemChangeManager, nodeIdentityResolver)
 {
     _catalog = catalogSystem;
 }
        protected void WalkCategoryTree(NodeContent node, 
            IContentRepository repository, 
            CatalogContentLoader contentLoader, 
            ICatalogSystem catalog,
            ReferenceConverter referenceConverter)
        {
            // ReSharper disable PossibleMultipleEnumeration
            // Get all products
            Stopwatch tmr = Stopwatch.StartNew();
            IEnumerable<EntryContentBase> entries = repository.GetChildren<EPiServer.Commerce.Catalog.ContentTypes.EntryContentBase>(node.ContentLink);
            _log.Debug("Loaded {0} entries in category {1} using IContentRepository in {2}ms",
                            entries.Count(),
                            node.Name,
                            tmr.ElapsedMilliseconds);

            // Load and cache Entry objects. Still a lot of code that uses this
            tmr = Stopwatch.StartNew();
            foreach (EntryContentBase entryAsContent in entries)
            {
                // Load full entry
                int entryId = referenceConverter.GetObjectId(entryAsContent.ContentLink);
                // Catalog Gadget uses info
                //catalog.GetCatalogEntry(entryId,
                //	new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryInfo));
                catalog.GetCatalogEntry(entryId,
                    new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull));
            }

            // Prime the catalog gadget
            // IEnumerable<IContent> children = repository.GetChildren<IContent>(node.ContentLink, new LanguageSelector("en"), 0, int.MaxValue);
            // _log.Debug("Loaded {0} children", children.Count());

            // .GetDescendents(node.ContentLink);

            tmr.Stop();
            _log.Debug("Loaded {0} entries in category {1} using ICatalogSystem in {2}ms",
                            entries.Count(),
                            node.Name,
                            tmr.ElapsedMilliseconds);

            // Get all products the way it is done in edit mode, but this does not seem to
            // use the cache.
            //int loadedEntries;
            //contentLoader.GetCatalogEntries(node.ContentLink, 0, int.MaxValue, out loadedEntries);
            //_log.Debug("Loaded {0} entries in category {1} using CatalogContentLoader", loadedEntries, node.Name);

            // Get child nodes the same way done by the UI
            IList<GetChildrenReferenceResult> catalogNodes = contentLoader.GetCatalogNodes(node.ContentLink);
            _log.Debug("Loaded {0} categories in category {1} using CatalogContentLoader", catalogNodes.Count, node.Name);
            foreach (GetChildrenReferenceResult catalogNode in catalogNodes)
            {
                NodeContent childNode = repository.Get<NodeContent>(catalogNode.ContentLink);
                WalkCategoryTree(childNode, repository, contentLoader, catalog, referenceConverter);
            }
            // ReSharper restore PossibleMultipleEnumeration
        }