Try our conversational search powered by Generative AI!

Exclude products from inactive catalogues

Vote:
 

We are running our site on 7.7.2 with Solr, and we keep getting search hits on products that belong to catalogues/folders that is set to availible = false, and I'm not really clear on how to exclude those folders in the criteria for the search method. The biggest issue is that you get 404 if you try to go to the product that belongs to that folder.

When we build up the criteria we are using this code snippet from EPiServers example code:

if (criteria.CatalogNames.Count == 0)
                {
                    var catalogs = CatalogContext.Current.GetCatalogDto();
                    if (catalogs.Catalog.Count > 0)
                    {                        
                        foreach (var row in catalogs.Catalog)
                        {                                                        
                            if (row.IsActive &&
                                row.StartDate <= frameworkcontext.current.currentdatetime &&>
                                row.EndDate >= FrameworkContext.Current.CurrentDateTime)
                            {
                                criteria.CatalogNames.Add(row.Name);
                            }
                        }
                    }
                }

So it only adds catalogues that is set to active, but if a child folder is inactive, we keep getting hits on the products from that catalogue, and those results in 404. How can I exclude those folders? Do I have to go through all child folders as well and only add the active ones? What about if a catalogue has for example two child catalogues and articles as well? And one of those catalogues is set to active = false, in so case I can't add the parent folder because it has a child folder that is set to active = false.

We are using the SearchFilterHelper.Current.SearchEntries method that needs the criteria.

Anyone with a solution on this?

/J

#113782
Nov 27, 2014 17:13
Vote:
 

Hi,

The reason the entries in inactive catalog nodes are not excluded because they can belong (linked) to another catalog nodes.

The solution I can think of is to create a new class inherits from BaseCatalogIndexBuilder, and override this method 

protected virtual void OnCatalogEntryIndex(ref SearchDocument document, CatalogEntryDto.CatalogEntryRow entry, string language)

to skip if the entry belongs to an inactive node.

Then update your Mediachase.Search.Config to use new class as your indexer.

Regards.

/Q

#113881
Dec 01, 2014 8:00
Vote:
 

Ok great, thanks for response!

#114116
Dec 04, 2014 16:13
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.