2

I am getting product ids from external product search system. I need them to be the result of search done through CatalogSearch.

I thought of adding a filter to searchCriteria in _renderFiltersBefore() function located in

app/code/Magento/CatalogSearch/Model/ResourceModel/Fulltext/Collection.php

like

$this->filterBuilder->setField('entity_id');
$this->filterBuilder->setValue([1,2,24]); // <-- product ids
$this->searchCriteriaBuilder->addFilter($this->filterBuilder->create());

but it doesn't seem there's a filter that could select products by ids.

I have also found addIdFilter($productId, $exclude = false) function in
app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php
but can't find a way to make use of it in CatalogSearch.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.