London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

Commerce entries search

Vote:
 

Hi.

I'm trying to find entries according to their start/end dates and it doesnt work. It just ignores start/end dates filter and returns all entries.

I'm using a standard lucene.net search provider, my entries are indexed.

Mediachase.Search.config



  
    
      
      
      
      
      
      
  
  
    
  

Search implementation

public IEnumerable SearchCatalogEntries(CommerceSearchQuery query)
        {
            if (query == null)
            {
                return Enumerable.Empty();
            }

            var searchCriteria = new CatalogEntrySearchCriteria
            {
                StartDate = query.DateFrom,
                EndDate = query.DateTo,
                Locale = "en",
                MarketId = _currentMarket.GetCurrentMarket().MarketId,
                StartingRecord = 0
            };

            switch (query.EntryType)
            {
                case CommerceSearchEntryType.Variant:
                    searchCriteria.ClassTypes.Add("variation");
                    break;
                case CommerceSearchEntryType.Product:
                    searchCriteria.ClassTypes.Add("product");
                    break;
            }

            var manager = new SearchManager(_applicationName);
            ISearchResults results;
            try
            {
                results = manager.Search(searchCriteria);
            }
            catch (Exception e)
            {
                _logger.Error(e.Message, e);

                return Enumerable.Empty();
            }
            if (results.Documents == null || results.TotalCount == 0)
            {
                return Enumerable.Empty();
            }

            return results.Documents.Select(x =>
            {
                var entryId = int.Parse(x["_id"].Value.ToString());
                var entryReference = _referenceConverter.GetContentLink(entryId, CatalogContentType.CatalogEntry, 0);
                IContent entry;
                _contentLoader.TryGet(entryReference, out entry);
                return entry as EntryContentBase;
            });
        }

Can someone help me to understand what's wrong?

Thanks.

#150954
Edited, Jul 05, 2016 11:36
Vote:
 

Hi,

I think this is missing, By default IncludePreorderEntry is true then the StartDate will no longer take effect

criteria.IncludePreorderEntry = false;



#150961
Jul 05, 2016 14:46
Vote:
 

Unfortunately, it doesn't help.

I chose the product for test, changed Allow Preorder to false for all product variants, rebuilded the index, but the product still in the returned documents from the search manager.

#150966
Jul 05, 2016 16:47
Vote:
 

No, I meant for this 

var searchCriteria = new CatalogEntrySearchCriteria

            {
                StartDate = query.DateFrom,
                EndDate = query.DateTo,
                Locale = "en",
                MarketId = _currentMarket.GetCurrentMarket().MarketId,
                StartingRecord = 0,
                        IncludePreOrderEntry = false
            };
#150975
Edited, Jul 05, 2016 17:13
Vote:
 

Yeah, of course I added that line

var searchCriteria = new CatalogEntrySearchCriteria
            {
                StartDate = query.DateFrom,
                EndDate = query.DateTo,
                IncludePreorderEntry = false,
                Locale = "en",
                MarketId = _currentMarket.GetCurrentMarket().MarketId,
                StartingRecord = 0
            };

But it didnt help, actually nothing changed.

#150988
Jul 06, 2016 11:10
Vote:
 

Hmm - which version are you on. I tested on our latest version and it seems to be working.

#151082
Jul 11, 2016 11:17
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.