Algolia Community

Display CMS pages on Magento 2 Instant Search page

instantsearch
magento2

#1

Is it possible to add page search results to the instant search results page in Magento 2? If so, how would I go about doing that?


#2

Hello @greg2,

it’s not possible with the standard functionality of the extension. Instant search is composed only from a results of one - products - index.

Could you elaborate a bit more on how and where you’d like to display the pages? Thank you!


CMS pages on Search Results page
CMS pages on Search Results page
#3

Hi,
I would like to show a list of results from the pages index in the sidebar of the instant search page below where the category matches are displayed.


#4

The categories in the sidebar are not “matched” categories, but it’s a category filter which refines products displayed in the main section of the page.

On the other hand, CMS pages are not tight to products as categories are. Therefore it cannot be filter.
If you want to display CMS pages there, based on the query you search for, you’ll need to create new search functionality.

You can use InstantSearch.js library and create your own JavaScript file where you define the search for CMS pages. You new instant search implementation can target the same search bar as the products search does and then only display matches pages in the sidebar. Would that work for you?


#5

Ok. I’ll take a look at that and see what I can do. Thanks for the help.


#6

When I search for a keyword I see the page in autocomplete menu:
Categories: 0 results
Pages: 1 result
Product 0 results
That’s ok.

But when I press enter and I go to https://www.domain.com/catalogsearch/result/?q=keyword I don’t see results. I want the page from the autocomplete menu also on “catalogsearch/result/?q=keyword”


#7

Hi @skan,

I would recommend following the solution listed on this thread by Jan. For the search results page powered by instantsearch, you’ll have to create a new instantsearch implementation for pages if you want to see pages in the result.