5 Replies Latest reply: Oct 5, 2012 2:18 PM by 966435 RSS

    Global Search

    965342
      Hi,

      I have a requirement as shown below.

      When user searches with productId/skuId in search box, then if the record exists in endeca then system has to redirect to Product details page.

      Please suggest me on this. Thanks in advance.
        • 1. Re: Global Search
          Michael Peel-Oracle
          Assuming Sku ID and/or Product ID is unique, then:

          If ( results.getNavigation() != null && results.getNavigation().getTotalNumberERecs() == 1 ) {
          String uniqueId = results.getNavigation().getERecs().get(0).getProperties().get("P_My_Unique_ID_for_my_Web_Application");
          // Forward to product page for specific product
          }

          If you are using aggregated records, replace getTotalNumberERecs() with getTotalNumberAggrERecs(), and getERecs().get(0) with getAggrERecs().get(0).getRepresentative() .

          Michael
          • 2. Re: Global Search
            965342
            Thanks michael for the response.

            Currently i am using ATG 10.1.1 with experience manager, As it uses the AssmblerPipelineServlet for processing the content items for pages( configured in experience manager) My question is do i need to have this recordcount check in AssmblerPipelineServlet.
            • 3. Re: Global Search
              Michael Peel-Oracle
              No idea how you would technically implement this using Assembler - I've not used it yet. Hopefully someone else can help!

              Michael
              • 4. Re: Global Search
                sean horgan - oracle
                You could start by taking a look at the discover electronics app, specifically the jsp & js under WEB-INF/views/desktop/SearchBox. You can see examples on processing dimension search results. Similar to the presentation API, you can examine the response to see if there was just one result and build an action string to point at a detail page.

                Sean
                • 5. Re: Global Search
                  966435
                  The application code would be similar in the Assembler context, with slightly different syntax. In the case of Assembler, you'll be looking in the contents of the returned ResultsList (com.endeca.infront.cartridge.ResultsList):

                  if (resultsList.getRecords() != null && resultsList.getRecords().size() == 1) {
                  String uniqueId = resultsList.getRecords().get(0).getAttributes().get("P_My_Unique_ID_for_my_Web_Application").get(0);
                  // Forward to product page for specific product
                  }