cancel
Showing results for 
Search instead for 
Did you mean: 

Show result of search based on customer attribute

Show result of search based on customer attribute

Hello,

 

I need to show the result of the research based on a customer attribute.

 

I've done this for the catalog, but I can't find the way to do it for the search result.

 

I tried to override Result.php, ListProduct.php and Layer.php from the magento_catalog_search module.

 

In the result.php, if I dump the result (after adding my filter thanks to addAttributeToFilter), it shows me the right result, but only as a dump (only array data, it doesn't affect the layout or the number of result in layered navigation.

 

How can I do that ?

1 REPLY 1

Re: Show result of search based on customer attribute

Hello @morgan_tartreau1 

 

For adding your custom filter for search results you need to add your conditions inside

Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection.php
inside _renderFiltersBefore function

you also need to add your attribute in search_request.xml if you want to filter with custom attribute by the same way it is present at
Magento/CatalogSearch/etc/search_request.xml

If my answer is useful Click kudos and Accept as Solution