Developer forum

Forum » Ecommerce - Standard features » Old Faithful ProductsAndGroupsHandler

Old Faithful ProductsAndGroupsHandler

Kevin O'Driscoll
Reply

Again, I need to implement some very special product filtering in DW (Version 8.9.2.6).

Ecom Catalog modules contain Product Groups and Smart Searches, Im using ProductsAndGroupsHandler to get the Groups and Products for each area (6) so I can construct my filtering criteria.

I see there is a new property on ProductsAndGroupsHandler SearchesSelected. (See screenshot attached below). The question is how should I use this output to return the SmartSearch result?

The Code:

            IEnumerable<Paragraph> areaModuleParagraphs = GetAreaModuleParagaraphs(areaId, "eCom_Catalog");

            foreach (var paragraph in areaModuleParagraphs)
            {
                Properties properties = Dynamicweb.Base.GetParagraphModuleSettings(paragraph.ID);
                ProductsAndGroupsHandler productGroupSelector = new ProductsAndGroupsHandler(properties["ProductAndGroupsSelector"]);
                productGroupSelector.IncludeSubgroups = true;

                if(productGroupSelector.SearchesSelected.Count() >0)
                {
                    string[] sa = productGroupSelector.SearchesSelected.ToArray();
                    // what to do with sa?
                }

                foreach (var group in productGroupSelector.GroupsSelected)
                {
                    Dynamicweb.eCommerce.Products.Group parent = new Dynamicweb.eCommerce.Products.Group();

Untitled.jpg

Replies

 
Nicolai Pedersen
Reply

You want to query the smartsearches?

This is how it is done in our code:

Private Function CreateSmartSearchesProductsIndex(productUniq As Func(Of Product, String)) As IDictionary(Of String, Product)
            Dim ret As New Dictionary(Of String, Product)
            For Each ssid As String In SearchesSelected
                Dim smartSearchId As Guid
                If Guid.TryParse(ssid, smartSearchId) Then
                    Dim ss As SmartSearch = SmartSearchManager.GetSmartSearchById(smartSearchId)
                    If ss IsNot Nothing Then
                        For Each p As Product In ss.GetResult(Of ProductCollection)()
                            Dim pid As String = productUniq(p)
                            If Not ret.ContainsKey(pid) Then
                                ret.Add(pid, p)
                            End If
                        Next
                    End If
                End If
            Next
            Return ret
        End Function
 
Kevin O'Driscoll
Reply

Hi Nicolai thanks for your very fast response, this looks like what I need however I cant reference SmartSearch SmartSearchManager am I missing a .dll? Im using DW 8.9.2.6

https://doc.dynamicweb.com/api/html/208d7c92-4e1d-2dcf-f7fc-29fb1c9890b3.htm tells me 

[ObsoleteAttribute("Use Dynamicweb.SmartSearch.SmartSearch instead")]
public class SmartSearch : SmartSearch

I find no reference to Dynamicweb.SmartSearch.SmartSearch in any documentation except DW9, do I pull a DW 9 .dll for this?

 

 
Nicolai Pedersen
Reply
This post has been marked as an answer

Hi Kevin

That is found in Dynamicweb.Modules.Searching.SmartSearch - but everything in there is not accesible from the outside for some reason... So that gets you stuck.

I can make it publically available in a service release.

NP

Votes for this answer: 1
 
Kevin O'Driscoll
Reply

OK I understand now why I couldnt get this. A service release would be fantastic for this version.

The project expects to upgrade to 9.x before phase 2 commencing in 8 weeks but I need to create some prototypes meanwhile.

K

 
Nicolai Pedersen
Reply

Smart searches for products does not exist in DW9 - they are replaced by the repositories that you also have in 8...

So you  might not want to do whatever you are doing using smartsearches.

BR Nicolai

 
Kevin O'Driscoll
Reply

I appreciate your advice, Nicolai, I would like to do both, looking at Repositories during Phase 2. (The client already implemented some smart searches for products as part of his cms admin in phase1).

Also I want to use Lucerne to index my results for filter criterion (which will be big data) and possibly have it rebuild after an integration import.

 

You must be logged in to post in the forum