SiteSearch

Adds global search capabilities to October CMS

Back to SiteSearch Support

xzealotx35188
xzealotx35188

I'm using mall, and I want to filter products by their categories, and than search only products in this category. Is it possible? If yes, where should I dig to do this?

OFFLINE
OFFLINE

This is not supported out-of-the-box but can be added easily:

Create your own search provider as described in the README.

Extend the ProductsSearchProvider and override it's searchProductsFromDefaultLocale and searchVariantsFromDefaultLocale methods with a whereHas('categories', ...) condition that includes the categories you wish to search for.

You can pass the categories along with your search form and access them using the post() helper.

xzealotx35188
xzealotx35188

Thank You so much!

xzealotx35188
xzealotx35188

I cant find my mistake - all works, but i have two serachresults, mine - from category, and second - from all products. I mean i have two queries, but I want only one - mine, from categories.

It works, if I just put my method into ProductsSearchProvider, but if I listen sitesearchextend i have two results of searching

Last updated

marius57803
marius57803

Hello, How could we deactivate JiriJKShopResultsProvider ? I extended sitesearch:

public function boot() { Event::listen('offline.sitesearch.extend', function () { return new JiriJKShopResultsExtendedProvider();

        // or
        // return [new DocumentsSearchProvider(), new FilesSearchProvider()]; 
    });
}

and now I want to disable JiriJKShopResultsProvider as it returns two results now.

Last updated

OFFLINE
OFFLINE

You can disable all built in providers via the backend settings.

marius57803
marius57803

My new provider does not seem to appear in backend, however it works. And when JiriJKShopResultsProvider is disabled it does not work anymore.

Last updated

OFFLINE
OFFLINE

Ah, now I see, you have extended the original provider. In this case you can override the isInstalledAndEnabled method in your provider and simply return true. This way, the built in provider will be disabled (via the backend settngs) but your custom provider will always be enabled:

https://github.com/OFFLINE-GmbH/oc-site-search-plugin/blob/develop/classes/providers/JiriJKShopResultsProvider.php#L75

marius57803
marius57803

Super thanks, that works !

1-9 of 9